Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Unified Diff: Source/core/css/StylePropertySet.cpp

Issue 169453006: Optimize StylePropertySet::findPropertyIndex() to improve CSS properties performance (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/StylePropertySet.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/StylePropertySet.cpp
diff --git a/Source/core/css/StylePropertySet.cpp b/Source/core/css/StylePropertySet.cpp
index 6a333f6651c74c93ae6c132b756039b17b4e69fc..96a40795f94253517b3ce2da4073c0b9aace3c53 100644
--- a/Source/core/css/StylePropertySet.cpp
+++ b/Source/core/css/StylePropertySet.cpp
@@ -94,6 +94,22 @@ ImmutableStylePropertySet::~ImmutableStylePropertySet()
valueArray[i]->deref();
}
+int ImmutableStylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const
+{
+ // Convert here propertyID into an uint16_t to compare it with the metadata's m_propertyID to avoid
+ // the compiler converting it to an int multiple times in the loop.
+ uint16_t id = static_cast<uint16_t>(propertyID);
+ for (int n = m_arraySize - 1 ; n >= 0; --n) {
+ if (metadataArray()[n].m_propertyID == id) {
+ // Only enabled or internal properties should be part of the style.
+ ASSERT(RuntimeCSSEnabled::isCSSPropertyEnabled(propertyID) || isInternalProperty(propertyID));
+ return n;
+ }
+ }
+
+ return -1;
+}
+
MutableStylePropertySet::MutableStylePropertySet(const StylePropertySet& other)
: StylePropertySet(other.cssParserMode())
{
@@ -422,21 +438,6 @@ bool MutableStylePropertySet::removePropertiesInSet(const CSSPropertyID* set, un
return changed;
}
-int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const
-{
- // Convert here propertyID into an uint16_t to compare it with the metadata's m_propertyID to avoid
- // the compiler converting it to an int multiple times in the loop.
- uint16_t id = static_cast<uint16_t>(propertyID);
- for (int n = propertyCount() - 1 ; n >= 0; --n) {
- if (id == propertyAt(n).propertyMetadata().m_propertyID) {
- // Only enabled or internal properties should be part of the style.
- ASSERT(RuntimeCSSEnabled::isCSSPropertyEnabled(propertyID) || isInternalProperty(propertyID));
- return n;
- }
- }
- return -1;
-}
-
CSSProperty* MutableStylePropertySet::findCSSPropertyWithID(CSSPropertyID propertyID)
{
int foundPropertyIndex = findPropertyIndex(propertyID);
@@ -511,6 +512,22 @@ CSSStyleDeclaration* MutableStylePropertySet::ensureCSSStyleDeclaration()
return m_cssomWrapper.get();
}
+int MutableStylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const
+{
+ // Convert here propertyID into an uint16_t to compare it with the metadata's m_propertyID to avoid
+ // the compiler converting it to an int multiple times in the loop.
+ uint16_t id = static_cast<uint16_t>(propertyID);
+ for (int n = m_propertyVector.size() - 1 ; n >= 0; --n) {
+ if (m_propertyVector.at(n).metadata().m_propertyID == id) {
+ // Only enabled or internal properties should be part of the style.
+ ASSERT(RuntimeCSSEnabled::isCSSPropertyEnabled(propertyID) || isInternalProperty(propertyID));
+ return n;
+ }
+ }
+
+ return -1;
+}
+
unsigned StylePropertySet::averageSizeInBytes()
{
// Please update this if the storage scheme changes so that this longer reflects the actual size.
« no previous file with comments | « Source/core/css/StylePropertySet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698