Little optimization for CSSParser::parseFillShorthand.
authoralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Feb 2012 17:35:17 +0000 (17:35 +0000)
committeralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Feb 2012 17:35:17 +0000 (17:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=79042

Reviewed by Hajime Morita.

Remove one extra loop that we can combine with the following one
which adds the properties to the parser's list of properties. I also
removed a useless check.
Instruments shows on the css-parser-yui benchmark an improvement
of 13ms (from 77ms spent in the function to 64ms).

No new tests : refactoring, existings tests should cover.

* css/CSSParser.cpp:
(WebCore::CSSParser::parseFillShorthand):

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

Source/WebCore/ChangeLog
Source/WebCore/css/CSSParser.cpp

index 761d6e3..0091858 100644 (file)
@@ -1,3 +1,21 @@
+2012-02-21  Alexis Menard  <alexis.menard@openbossa.org>
+
+        Little optimization for CSSParser::parseFillShorthand.
+        https://bugs.webkit.org/show_bug.cgi?id=79042
+
+        Reviewed by Hajime Morita.
+
+        Remove one extra loop that we can combine with the following one
+        which adds the properties to the parser's list of properties. I also
+        removed a useless check.
+        Instruments shows on the css-parser-yui benchmark an improvement
+        of 13ms (from 77ms spent in the function to 64ms).
+
+        No new tests : refactoring, existings tests should cover.
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseFillShorthand):
+
 2012-02-20  David Hyatt  <hyatt@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=79046
index 54fdcf3..5ebdf30 100644 (file)
@@ -2481,23 +2481,20 @@ bool CSSParser::parseFillShorthand(int propId, const int* properties, int numPro
             return false;
     }
 
-    // Fill in any remaining properties with the initial value.
-    for (i = 0; i < numProperties; ++i) {
+    // Now add all of the properties we found.
+    for (i = 0; i < numProperties; i++) {
+        // Fill in any remaining properties with the initial value.
         if (!parsedProperty[i]) {
             addFillValue(values[i], cssValuePool()->createImplicitInitialValue());
             if (properties[i] == CSSPropertyBackgroundPosition || properties[i] == CSSPropertyWebkitMaskPosition)
                 addFillValue(positionYValue, cssValuePool()->createImplicitInitialValue());
             if (properties[i] == CSSPropertyBackgroundRepeat || properties[i] == CSSPropertyWebkitMaskRepeat)
                 addFillValue(repeatYValue, cssValuePool()->createImplicitInitialValue());
-            if ((properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin) && !parsedProperty[i]) {
+            if ((properties[i] == CSSPropertyBackgroundOrigin || properties[i] == CSSPropertyWebkitMaskOrigin)) {
                 // If background-origin wasn't present, then reset background-clip also.
                 addFillValue(clipValue, cssValuePool()->createImplicitInitialValue());
             }
         }
-    }
-
-    // Now add all of the properties we found.
-    for (i = 0; i < numProperties; i++) {
         if (properties[i] == CSSPropertyBackgroundPosition) {
             addProperty(CSSPropertyBackgroundPositionX, values[i].release(), important);
             // it's OK to call positionYValue.release() since we only see CSSPropertyBackgroundPosition once