Title: [144682] trunk/Source/WebCore
Revision
144682
Author
[email protected]
Date
2013-03-04 15:09:29 -0800 (Mon, 04 Mar 2013)

Log Message

CSSParser: Avoid temporary String when parsing hex colors.
<http://webkit.org/b/111341>

Reviewed by Anders Carlsson.

Templatize CSSParser::fastParseColor() so we can pass a CSSParserString as the color name.
This avoids creating a temporary WTF::String from the parser string.

* css/CSSParser.cpp:
(WebCore::CSSParser::fastParseColor):
* css/CSSParser.h:
* css/CSSParserValues.h:
(CSSParserString):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (144681 => 144682)


--- trunk/Source/WebCore/ChangeLog	2013-03-04 23:07:45 UTC (rev 144681)
+++ trunk/Source/WebCore/ChangeLog	2013-03-04 23:09:29 UTC (rev 144682)
@@ -1,3 +1,19 @@
+2013-03-04  Andreas Kling  <[email protected]>
+
+        CSSParser: Avoid temporary String when parsing hex colors.
+        <http://webkit.org/b/111341>
+
+        Reviewed by Anders Carlsson.
+
+        Templatize CSSParser::fastParseColor() so we can pass a CSSParserString as the color name.
+        This avoids creating a temporary WTF::String from the parser string.
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::fastParseColor):
+        * css/CSSParser.h:
+        * css/CSSParserValues.h:
+        (CSSParserString):
+
 2013-03-04  Julien Chaffraix  <[email protected]>
 
         [CSS Grid Layout] Add parsing for grid-{start|before}

Modified: trunk/Source/WebCore/css/CSSParser.cpp (144681 => 144682)


--- trunk/Source/WebCore/css/CSSParser.cpp	2013-03-04 23:07:45 UTC (rev 144681)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2013-03-04 23:09:29 UTC (rev 144682)
@@ -5951,7 +5951,8 @@
     return false;
 }
 
-bool CSSParser::fastParseColor(RGBA32& rgb, const String& name, bool strict)
+template<typename StringType>
+bool CSSParser::fastParseColor(RGBA32& rgb, const StringType& name, bool strict)
 {
     unsigned length = name.length();
     bool parseResult;
@@ -5962,7 +5963,7 @@
     if (name.is8Bit())
         parseResult = fastParseColorInternal(rgb, name.characters8(), length, strict);
     else
-        parseResult = fastParseColorInternal(rgb, name.characters(), length, strict);
+        parseResult = fastParseColorInternal(rgb, name.characters16(), length, strict);
 
     if (parseResult)
         return true;
@@ -5975,7 +5976,6 @@
         return true;
     }
     return false;
-
 }
     
 inline double CSSParser::parsedDouble(CSSParserValue *v, ReleaseParsedCalcValueCondition releaseCalc)

Modified: trunk/Source/WebCore/css/CSSParser.h (144681 => 144682)


--- trunk/Source/WebCore/css/CSSParser.h	2013-03-04 23:07:45 UTC (rev 144681)
+++ trunk/Source/WebCore/css/CSSParser.h	2013-03-04 23:09:29 UTC (rev 144682)
@@ -183,7 +183,8 @@
     bool parseColorFromValue(CSSParserValue*, RGBA32&);
     void parseSelector(const String&, CSSSelectorList&);
 
-    static bool fastParseColor(RGBA32&, const String&, bool strict);
+    template<typename StringType>
+    static bool fastParseColor(RGBA32&, const StringType&, bool strict);
 
     bool parseLineHeight(bool important);
     bool parseFontSize(bool important);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to