Skip to content

rule_order: drop shadowed declarations in one backward pass - #218

Open
samoht wants to merge 1 commit into
speed-canonical-difffrom
speed-canonical-pass
Open

rule_order: drop shadowed declarations in one backward pass#218
samoht wants to merge 1 commit into
speed-canonical-difffrom
speed-canonical-pass

Conversation

@samoht

@samoht samoht commented Jul 30, 2026

Copy link
Copy Markdown
Owner

canonicalize_rule_order on a 660KB stylesheet went from 2.90s to 0.62s, with byte-identical output.

drop_shadowed_declarations asked, for every declaration of every rule, whether any later rule with the same selector writes that property, and answered by rescanning the whole tail and serialising each later rule's selector again. Walking the list backwards and carrying a per-selector set of the properties written later answers the same question with a lookup.

This is a regression against 1.0.0 rather than a long-standing cost: the function arrived in 923d09f, after the release. On the same input 1.0.0 takes 22.5s end to end and current main 34.5s; this branch is 24.0s while doing strictly more work in the projection than 1.0.0 did.

Stacked on #217; review that first.

For every declaration of every rule the shadow check rescanned the whole
tail, serialising each later rule's selector again to compare it. Walking
backwards and carrying a per-selector set of the properties written later
answers the same question with a lookup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant