Index style rules by their rightmost simple selector#4163
Draft
vogella wants to merge 1 commit into
Draft
Conversation
computeStyle tested every selector alternative of every rule against every element. RuleIndex buckets each alternative by the id, class, or element type its rightmost compound requires; alternatives without such a key (universal, attribute-only or pseudo-only compounds) go into a remainder bucket consulted for every element. A lookup gathers the buckets the element satisfies and hands the candidates to the matcher in cascade order, so match positions and cascade results are unchanged. RuleIndexTest locks the completeness invariant: over a stylesheet covering every selector shape, the index never drops an alternative the matcher would accept.
vogella
added a commit
to vogella/eclipse.platform.ui
that referenced
this pull request
Jul 4, 2026
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
computeStyle tested every selector alternative of every rule against every element, the main cost of a theme swap. A new RuleIndex buckets each alternative by the id, class, or element type its rightmost compound requires (universal, attribute-only and pseudo-only alternatives go into a remainder bucket consulted for every element), and the matcher now runs only on the candidates an element can possibly match, in unchanged cascade order. Styling results are identical: match positions are preserved, and the new RuleIndexTest locks the invariant that the index never drops an alternative the matcher would accept, checked over a stylesheet covering every selector shape.
Measured with a workbench theme-swap benchmark (20 editors, about 4000 widgets, 10 swap rounds per direction), engine applyStyles time fell from 196.6 to 155.6 microseconds per call and from 3.34 to 2.65 seconds per swap, about 21 percent less styling work per theme change, with identical call counts confirming unchanged behavior.
Part of #3980.