Slightly improve performance of CSSStyleApplyProperty handler lookup.
authormacpherson@chromium.org <macpherson@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Sep 2011 23:24:53 +0000 (23:24 +0000)
committermacpherson@chromium.org <macpherson@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Sep 2011 23:24:53 +0000 (23:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68868

Reviewed by Eric Seidel.

No new tests as no functionality changed.

* css/CSSStyleApplyProperty.h:
(WebCore::CSSStyleApplyProperty::propertyHandler):
Make propertyHandler() public and remove redirecting functions.
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty):
Perform property handler lookup once and reuse the result.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96168 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/css/CSSStyleApplyProperty.h
Source/WebCore/css/CSSStyleSelector.cpp

index 4b4952e..b8e116c 100644 (file)
@@ -1,3 +1,19 @@
+2011-09-27  Luke Macpherson   <macpherson@chromium.org>
+
+        Slightly improve performance of CSSStyleApplyProperty handler lookup.
+        https://bugs.webkit.org/show_bug.cgi?id=68868
+
+        Reviewed by Eric Seidel.
+
+        No new tests as no functionality changed.
+
+        * css/CSSStyleApplyProperty.h:
+        (WebCore::CSSStyleApplyProperty::propertyHandler):
+        Make propertyHandler() public and remove redirecting functions.
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+        Perform property handler lookup once and reuse the result.
+
 2011-09-27  Kent Tamura  <tkent@chromium.org>
 
         [V8] element.dataset.nonExistingKey should return undefined.
index e36580f..36e7e1c 100644 (file)
@@ -49,29 +49,11 @@ class CSSStyleApplyProperty {
 public:
     static const CSSStyleApplyProperty& sharedCSSStyleApplyProperty();
 
-    void applyInheritValue(CSSPropertyID property, CSSStyleSelector* selector) const
-    {
-        ASSERT(implements(property));
-        propertyHandler(property)->applyInheritValue(selector);
-    }
-
-    void applyInitialValue(CSSPropertyID property, CSSStyleSelector* selector) const
-    {
-        ASSERT(implements(property));
-        propertyHandler(property)->applyInitialValue(selector);
-    }
-
-    void applyValue(CSSPropertyID property, CSSStyleSelector* selector, CSSValue* value) const
-    {
-        ASSERT(implements(property));
-        propertyHandler(property)->applyValue(selector, value);
-    }
-
-    bool implements(CSSPropertyID property) const
+    ApplyPropertyBase* propertyHandler(CSSPropertyID property) const
     {
-        return propertyHandler(property);
+        ASSERT(valid(property));
+        return m_propertyMap[index(property)];
     }
-
 private:
     CSSStyleApplyProperty();
     static int index(CSSPropertyID property)
@@ -100,12 +82,6 @@ private:
         m_propertyMap[index(newProperty)] = m_propertyMap[index(equivalentProperty)];
     }
 
-    ApplyPropertyBase* propertyHandler(CSSPropertyID property) const
-    {
-        ASSERT(valid(property));
-        return m_propertyMap[index(property)];
-    }
-
     ApplyPropertyBase* m_propertyMap[numCSSProperties];
 };
 
index 64dc479..8c16911 100644 (file)
@@ -2371,13 +2371,13 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
     CSSPropertyID property = static_cast<CSSPropertyID>(id);
 
     // check lookup table for implementations and use when available
-    if (m_applyProperty.implements(property)) {
+    if (ApplyPropertyBase* handler = m_applyProperty.propertyHandler(property)) {
         if (isInherit)
-            m_applyProperty.applyInheritValue(property, this);
+            handler->applyInheritValue(this);
         else if (isInitial)
-            m_applyProperty.applyInitialValue(property, this);
+            handler->applyInitialValue(this);
         else
-            m_applyProperty.applyValue(property, this, value);
+            handler->applyValue(this, value);
         return;
     }