-
Notifications
You must be signed in to change notification settings - Fork 757
Description
Spun out from something I noticed in #12187: The "shorthand loop" of this algorithm does redundant work each loop iteration:
- Let
longhandsbe 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:
- Append all CSS declarations in
longhandsthat have a property name that maps to shorthand tocurrent longhands.
(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.)