Open Bug 128743 Opened 23 years ago Updated 2 years ago

Clean up GetRuleCascade so it uses array access rather than enumeration callbacks

Categories

(Core :: CSS Parsing and Computation, defect, P4)

defect

Tracking

()

Future

People

(Reporter: dbaron, Unassigned)

References

Details

(Keywords: perf, Whiteboard: [whitebox])

Attachments

(1 file, 4 obsolete files)

Clean up GetRuleCascade (and the enumeration callbacks it uses) by changing all the things that use enumerators to use array access. This should make it both easier to understand and faster.
Keywords: perf
Status: NEW → ASSIGNED
Priority: -- → P2
Target Milestone: --- → Future
To do this, I'd want to add an |UnsafeElementAt| to nsVoidArray that assumes the element is within the bounds -- i.e., that neither has bounds-checking *nor* null-checking of mImpl.
Target Milestone: Future → mozilla1.1
Attached patch some cleanup work that partially does this (obsolete) (deleted) — Splinter Review
Attached patch yet more cleanup work (obsolete) (deleted) — Splinter Review
This includes some stuff that I noticed while looking into bug 137247.
Attachment #78049 - Attachment is obsolete: true
Attached patch be good and use PR_BEGIN_MACRO / PR_END_MACRO (obsolete) (deleted) — Splinter Review
I'll future-proof these macros with PR_{BEGIN,END}_MACRO too...
Attachment #79163 - Attachment is obsolete: true
OK, a summary of what this patch does so far (the bigger changes are at the end): * removes |EVENT_DEBUG| define that doesn't correspond to any code * removes heavily bitrotted DEBUG_RULES debugging code (makes no sense with the rule tree, and I see no need to rewrite it since nobody seems to need it) * macro-izes my RULE_HASH_STATS stuff so it takes up less room * Comments HasStateDependentStyle better, and makes a performance optimization to |IsStateSelector| since it was testing for many selectors for which HasStatetDependentStyle will never be called. This is the part that is a followup to bug 5693 (see comment 3). * Redoes GetRuleCascade a bit by: + sorting the final array in the reverse order to allow elimination of AppendRuleToArray in favor of nsISupportsArray::AppendElements. (This change is a little confusing: we build the final array by combining a bunch of order-sorted arrays for each weight. So the change is to sort the weight arrays in the reverse order and then combine the arrays by a simple append instead of appending through EnumerateBackwards. Then, of course, it also changes the enumeration order of this final array.) + merges BuildStateEnum and BuildHashEnum
- (pseudoClass->mAtom == nsCSSAtoms::dragPseudo) || - (pseudoClass->mAtom == nsCSSAtoms::selectionPseudo) || I assume that drag and selection are both supposed to fire notifications that cause these pseudos to be applied as needed, which is why we don't need them here? > /** > * Takes the hashtable of arrays (keyed by weight, in order sort) and > * puts them all in one big array which has a primary sort by weight > * and secondary sort by reverse order. > */ This comment could use some changing, methinks, to indicate that the primary sort is now by reverse weight and the secondary sort is by order. That seems fishy, by the way. I would expect the new way to have a sort by reverse weight and secondary sort by reverse order, so that the first thing in the list is the thing of highest weight that came latest. I'm guessing the comment is wrong to start with about the sort orders of the arrays? The last looks good.
Er, the _rest_ looks good. :)
Actually, drag and selection pseudos aren't implemented, and should probably be completely removed (perhaps as part of bug 3935). :selection isn't even a pseudo-class -- it's a pseudo-element! A corrected comment is: /** * Takes the hashtable of arrays (keyed by weight, in order sort) and * puts them all in one big array which has a primary sort by weight * and secondary sort by order. */ (change "reverse order" to "order") Now that I notice it, I could probably also change AppendRuleToTable to PrependRuleToTable at some point in the future, and fix the worst-case O(N^2) (cumulatively) insertion into the rule hash. Maybe I'll do that now...
Actually, no, that would be a bit of a pain unless I convert to pldhash, which would make this patch even more confusing than it is already. But I'll toss in an XXX comment.
Attachment #79164 - Attachment is obsolete: true
Comment on attachment 79188 [details] [diff] [review] more/better comments, in response to bzbarsky r=bzbarsky
Attachment #79188 - Flags: review+
Comment on attachment 79188 [details] [diff] [review] more/better comments, in response to bzbarsky sr=waterson, although I'd have left the empty macros...well, empty.
Attachment #79188 - Flags: superreview+
Attachment 79188 [details] [diff] checked in to trunk, 2002-04-15 15:49 PDT. Leaving bug open for further work.
Attached patch failed attempt to convert to pldhash (obsolete) (deleted) — Splinter Review
This crashes on startup in unrelated code, and I haven't figured out why.
Attachment #81286 - Flags: needs-work+
The above patch should really go on bug 112318.
cc'ing myself
Comment on attachment 81286 [details] [diff] [review] failed attempt to convert to pldhash There is now a working patch on bug 112318 that replaces this one.
Attachment #81286 - Attachment is obsolete: true
Target Milestone: mozilla1.1alpha → Future
Depends on: 112318
Whiteboard: [dev notes]
Whiteboard: [dev notes] → [whitebox]
Assignee: dbaron → nobody
Status: ASSIGNED → NEW
QA Contact: ian → style-system
Summary: Clean up GetRuleCascade → Clean up GetRuleCascade so it uses array access rather than enumeration callbacks
Priority: P2 → P4
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: