From 3f5f64b4d86615f49e14a84a64d1eb682e7b9701 Mon Sep 17 00:00:00 2001 From: "alexis.menard@openbossa.org" Date: Tue, 21 Feb 2012 17:35:17 +0000 Subject: [PATCH] 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): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108365 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 18 ++++++++++++++++++ Source/WebCore/css/CSSParser.cpp | 11 ++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 761d6e3..0091858 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,21 @@ +2012-02-21 Alexis Menard + + 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 https://bugs.webkit.org/show_bug.cgi?id=79046 diff --git a/Source/WebCore/css/CSSParser.cpp b/Source/WebCore/css/CSSParser.cpp index 54fdcf3..5ebdf30 100644 --- a/Source/WebCore/css/CSSParser.cpp +++ b/Source/WebCore/css/CSSParser.cpp @@ -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 -- 2.7.4