Closed Bug 310236 Opened 20 years ago Closed 20 years ago

Cache nsAttrValue* for class attribute

Categories

(Core :: CSS Parsing and Computation, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bryner, Assigned: bryner)

Details

(Keywords: perf)

Attachments

(1 file)

We can speed up nsCSSRuleProcessor::RulesMatching() by only fetching the class attribute for the element once, instead of on each trip through SelectorMatches().
Attached patch patchSplinter Review
Attachment #197625 - Flags: superreview?(dbaron)
Attachment #197625 - Flags: review?(dbaron)
Comment on attachment 197625 [details] [diff] [review] patch >Index: content/base/src/nsAttrValue.cpp >+ nsIAtom* atom = NS_STATIC_CAST(nsIAtom*, GetPtr()); This should be nsIAtom* atom = GetAtomValue(); (It was that way in the code you moved.) >+ PRInt32 i, count = array->Count(); >+ for (i = 0; i < count; ++i) { This would be better all inside the for(): for (PRInt32 i = 0, count = array->Count(); i < count; ++i) {
Attachment #197625 - Flags: superreview?(dbaron)
Attachment #197625 - Flags: superreview+
Attachment #197625 - Flags: review?(dbaron)
Attachment #197625 - Flags: review+
checked in
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
What is the lifetime of the RuleProcessorData? The nsAttrValue pointer is only valid until someone adds or removes children or attributes from the element.
> What is the lifetime of the RuleProcessorData? Until we finish resolving style for this node. It's basically stack-allocated for the duration of style resolution; no document mutations can happen while one is alive.
It's either stack allocated or heap-allocated and owned by a stack-allocated object, so things should be fine. The lifetime is the lifetime of the nsStyleSet::{ResolveStyleFor,ResolvePseudoStyleFor,ProbePseudoStyleFor} function call.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: