Title: [274566] trunk/Source/WebCore
Revision
274566
Author
commit-qu...@webkit.org
Date
2021-03-17 10:22:43 -0700 (Wed, 17 Mar 2021)

Log Message

Use ASCIILiteral over String for CSSValue::separatorCSSText() to avoid allocation
https://bugs.webkit.org/show_bug.cgi?id=223300

Patch by Tyler Wilcock <twilc...@protonmail.com> on 2021-03-17
Reviewed by Yusuke Suzuki.

Use ASCIILiteral over String for CSSValue::separatorCSSText() to avoid
allocation, since we know this function will always return an
ASCII string.  Also rename separatorCssText to separatorCSSText.

These changes were requested in this comment:
https://bugs.webkit.org/show_bug.cgi?id=223205#c8

* css/CSSValue.cpp:
(WebCore::CSSValue::separatorCSSText const):
(WebCore::CSSValue::separatorCssText const):
Rename function separatorCssText to separatorCSSText.

* css/CSSValue.h:
String CSSValue::separatorCssText --> ASCIILiteral CSSValue::separatorCSSText

* css/CSSValueList.cpp:
(WebCore::CSSValueList::customCSSText const):
Use auto to capture result of separatorCSSText().

* css/CSSValuePair.cpp:
(WebCore::CSSValuePair::customCSSText const):
Function separatorCssText was renamed to separatorCSSText.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (274565 => 274566)


--- trunk/Source/WebCore/ChangeLog	2021-03-17 17:09:04 UTC (rev 274565)
+++ trunk/Source/WebCore/ChangeLog	2021-03-17 17:22:43 UTC (rev 274566)
@@ -1,3 +1,33 @@
+2021-03-17  Tyler Wilcock  <twilc...@protonmail.com>
+
+        Use ASCIILiteral over String for CSSValue::separatorCSSText() to avoid allocation
+        https://bugs.webkit.org/show_bug.cgi?id=223300
+
+        Reviewed by Yusuke Suzuki.
+
+        Use ASCIILiteral over String for CSSValue::separatorCSSText() to avoid
+        allocation, since we know this function will always return an
+        ASCII string.  Also rename separatorCssText to separatorCSSText.
+
+        These changes were requested in this comment:
+        https://bugs.webkit.org/show_bug.cgi?id=223205#c8
+
+        * css/CSSValue.cpp:
+        (WebCore::CSSValue::separatorCSSText const):
+        (WebCore::CSSValue::separatorCssText const):
+        Rename function separatorCssText to separatorCSSText.
+
+        * css/CSSValue.h:
+        String CSSValue::separatorCssText --> ASCIILiteral CSSValue::separatorCSSText
+
+        * css/CSSValueList.cpp:
+        (WebCore::CSSValueList::customCSSText const):
+        Use auto to capture result of separatorCSSText().
+
+        * css/CSSValuePair.cpp:
+        (WebCore::CSSValuePair::customCSSText const):
+        Function separatorCssText was renamed to separatorCSSText.
+
 2021-03-17  Martin Robinson  <mrobin...@igalia.com>
 
         REGRESSION (r272019): Momentum scrolling in proximity css-scroll-snap scroll areas broken

Modified: trunk/Source/WebCore/css/CSSValue.cpp (274565 => 274566)


--- trunk/Source/WebCore/css/CSSValue.cpp	2021-03-17 17:09:04 UTC (rev 274565)
+++ trunk/Source/WebCore/css/CSSValue.cpp	2021-03-17 17:22:43 UTC (rev 274566)
@@ -341,7 +341,7 @@
     return String();
 }
 
-String CSSValue::separatorCssText() const
+ASCIILiteral CSSValue::separatorCSSText() const
 {
     switch (m_valueSeparator) {
     case SpaceSeparator:

Modified: trunk/Source/WebCore/css/CSSValue.h (274565 => 274566)


--- trunk/Source/WebCore/css/CSSValue.h	2021-03-17 17:09:04 UTC (rev 274565)
+++ trunk/Source/WebCore/css/CSSValue.h	2021-03-17 17:22:43 UTC (rev 274566)
@@ -27,6 +27,7 @@
 #include <wtf/RefPtr.h>
 #include <wtf/TypeCasts.h>
 #include <wtf/URLHash.h>
+#include <wtf/text/ASCIILiteral.h>
 
 namespace WebCore {
 
@@ -77,7 +78,7 @@
 
     Type cssValueType() const;
     String cssText() const;
-    String separatorCssText() const;
+    ASCIILiteral separatorCSSText() const;
 
     bool isPrimitiveValue() const { return m_classType == PrimitiveClass; }
     bool isValueList() const { return m_classType >= ValueListClass; }

Modified: trunk/Source/WebCore/css/CSSValueList.cpp (274565 => 274566)


--- trunk/Source/WebCore/css/CSSValueList.cpp	2021-03-17 17:09:04 UTC (rev 274565)
+++ trunk/Source/WebCore/css/CSSValueList.cpp	2021-03-17 17:22:43 UTC (rev 274566)
@@ -86,7 +86,7 @@
 String CSSValueList::customCSSText() const
 {
     StringBuilder result;
-    String separator = separatorCssText();
+    auto separator = separatorCSSText();
     for (auto& value : m_values) {
         if (!result.isEmpty())
             result.append(separator);

Modified: trunk/Source/WebCore/css/CSSValuePair.cpp (274565 => 274566)


--- trunk/Source/WebCore/css/CSSValuePair.cpp	2021-03-17 17:09:04 UTC (rev 274565)
+++ trunk/Source/WebCore/css/CSSValuePair.cpp	2021-03-17 17:22:43 UTC (rev 274566)
@@ -36,7 +36,7 @@
     String second = this->second()->cssText();
     if (m_encoding == IdenticalValueEncoding::Coalesce && first == second)
         return first;
-    return makeString(first, separatorCssText(), second);
+    return makeString(first, separatorCSSText(), second);
 }
 
 bool CSSValuePair::equals(const CSSValuePair &other) const
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to