You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Spun out from something I noticed in #12187: The "shorthand loop" of this algorithm does redundant work each loop iteration:
Let longhands be an array consisting of all CSS declarations in declaration block’s declarations that that are not in already serialized and have a property name that maps to one of the shorthand properties in shorthands.
It's then only used to populate current longhands with a subset of its contents:
(It's also used in step 2 to reject shorthand if it doesn't have what it needs - but that could easily use current longhands instead.)
longhands itself doesn't serve any purpose as-is, it just is an extra array to allocate and add items to. I suspect the intention was as an optimization: If we only populate longhands once, before the loop, then it gives us a shorter list to iterate on each loop iteration, instead of having to look at every declaration each time. (I'm not convinced that would always be faster, fwiw, and it's unusual for a spec algorithm to attempt to optimize things.)
The text was updated successfully, but these errors were encountered:
In my opinion, populating longhands in the shorthand loop is appropriate because most properties are not mapped by a shorthand, and even fewer are mapped by more than one shorthand.
You can populate longhands before the shorthand loop and skip doing it when shorthands is empty, but I am not convinced that would be clearer in the spec, or faster in implementations.
Spun out from something I noticed in #12187: The "shorthand loop" of this algorithm does redundant work each loop iteration:
It's then only used to populate
current longhands
with a subset of its contents:(It's also used in step 2 to reject
shorthand
if it doesn't have what it needs - but that could easily usecurrent longhands
instead.)longhands
itself doesn't serve any purpose as-is, it just is an extra array to allocate and add items to. I suspect the intention was as an optimization: If we only populatelonghands
once, before the loop, then it gives us a shorter list to iterate on each loop iteration, instead of having to look at every declaration each time. (I'm not convinced that would always be faster, fwiw, and it's unusual for a spec algorithm to attempt to optimize things.)The text was updated successfully, but these errors were encountered: