Cache nsAttrValue* for class attribute

RESOLVED FIXED

Status

()

Core
CSS Parsing and Computation
RESOLVED FIXED
13 years ago
13 years ago

People

(Reporter: Brian Ryner (not reading), Assigned: Brian Ryner (not reading))

Tracking

({perf})

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

13 years ago
We can speed up nsCSSRuleProcessor::RulesMatching() by only fetching the class
attribute for the element once, instead of on each trip through SelectorMatches().
(Assignee)

Comment 1

13 years ago
Created attachment 197625 [details] [diff] [review]
patch
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+
(Assignee)

Comment 3

13 years ago
checked in
Status: NEW → RESOLVED
Last Resolved: 13 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.