[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/khtml/css
From: Viacheslav Tokarev <tsjoker () gmail ! com>
Date: 2009-03-13 2:21:47
Message-ID: 1236910907.103790.30685.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 938809 by vtokarev:
Sort only matched selectors before collecting properties
should save lots of CPU cycles
M +22 -12 cssstyleselector.cpp
--- trunk/KDE/kdelibs/khtml/css/cssstyleselector.cpp #938808:938809
@@ -660,32 +660,42 @@
tagCache.add(localNamePart(current->id()));
}
- // sort selectors indexes so we match them in increasing order
- qSort(selectorsForCheck.data(), selectorsForCheck.data() + \
selectorsForCheck.size());
-
propsToApply.clear();
pseudoProps.clear();
// now go over selectors that we prepared for check
+ // selectors yet in random order, so we store only matched selector indexes to \
sort after + unsigned amountOfMatchedSelectors = 0;
for (int k = 0; k < selectorsForCheck.size(); ++k) {
unsigned i = selectorsForCheck[k];
quint16 tag = selectors[i]->tagLocalName.id();
if (cssTagId == tag || tag == anyLocalName) {
++schecked;
checkSelector(i, e);
- if (selectorCache[i].state == Applies) {
- ++smatch;
- for (unsigned p = selectorCache[i].firstPropertyIndex; p < \
properties_size; p = nextPropertyIndexes[p])
- propsToApply.append(propertiesBuffer + p);
- } else if (selectorCache[i].state == AppliesPseudo) {
- for (unsigned p = selectorCache[i].firstPropertyIndex; p < \
properties_size; p = nextPropertyIndexes[p]) {
- pseudoProps.append(propertiesBuffer + p);
- propertiesBuffer[p].pseudoId = (RenderStyle::PseudoId) \
selectors[i]->pseudoId;
- }
+ if (selectorCache[i].state == Applies || selectorCache[i].state == \
AppliesPseudo) { + selectorsForCheck[amountOfMatchedSelectors++] = i;
}
} else
selectorCache[i].state = Invalid;
}
+ // sort only matched selectors and then collect properties
+ qSort(selectorsForCheck.data(), selectorsForCheck.data() + \
amountOfMatchedSelectors); + for (unsigned k = 0; k < amountOfMatchedSelectors; \
++k) { + unsigned i = selectorsForCheck[k];
+ if (selectorCache[i].state == Applies) {
+ ++smatch;
+ for (unsigned p = selectorCache[i].firstPropertyIndex; p < \
properties_size; p = nextPropertyIndexes[p]) + \
propsToApply.append(propertiesBuffer + p); + } else if (selectorCache[i].state \
== AppliesPseudo) { + for (unsigned p = \
selectorCache[i].firstPropertyIndex; p < properties_size; p = nextPropertyIndexes[p]) \
{ + pseudoProps.append(propertiesBuffer + p);
+ propertiesBuffer[p].pseudoId = (RenderStyle::PseudoId) \
selectors[i]->pseudoId; + }
+ }
+ }
+ // clear selectorsForCheck, it shouldn't be used after
+ selectorsForCheck.clear();
+
// Inline style declarations, after all others.
// Non-css hints from presentational attributes will also be collected here
// receiving the proper priority so has to cascade from before author rules \
(cf.CSS 2.1-6.4.4).
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic