Title: [238089] trunk/Source/WebCore
Revision
238089
Author
commit-qu...@webkit.org
Date
2018-11-12 08:49:50 -0800 (Mon, 12 Nov 2018)

Log Message

CSSCalcOperation constructor wastes 6KB of Vector capacity on cnn.com
https://bugs.webkit.org/show_bug.cgi?id=190839

Patch by Rob Buis <rb...@igalia.com> on 2018-11-12
Reviewed by Frédéric Wang.

The CSSCalcOperation ctor that takes a leftSide and rightSide parameter
wastes memory since it will always have size 2 but claims the
default Vector size. So make sure to reserve an initial capacity of 2.

* css/CSSCalculationValue.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (238088 => 238089)


--- trunk/Source/WebCore/ChangeLog	2018-11-12 16:48:22 UTC (rev 238088)
+++ trunk/Source/WebCore/ChangeLog	2018-11-12 16:49:50 UTC (rev 238089)
@@ -1,3 +1,16 @@
+2018-11-12  Rob Buis  <rb...@igalia.com>
+
+        CSSCalcOperation constructor wastes 6KB of Vector capacity on cnn.com
+        https://bugs.webkit.org/show_bug.cgi?id=190839
+
+        Reviewed by Frédéric Wang.
+
+        The CSSCalcOperation ctor that takes a leftSide and rightSide parameter
+        wastes memory since it will always have size 2 but claims the
+        default Vector size. So make sure to reserve an initial capacity of 2.
+
+        * css/CSSCalculationValue.cpp:
+
 2018-11-12  Yusuke Suzuki  <yusukesuz...@slowstart.org>
 
         WTFMove(xxx) is used in arguments while other arguments touch xxx

Modified: trunk/Source/WebCore/css/CSSCalculationValue.cpp (238088 => 238089)


--- trunk/Source/WebCore/css/CSSCalculationValue.cpp	2018-11-12 16:48:22 UTC (rev 238088)
+++ trunk/Source/WebCore/css/CSSCalculationValue.cpp	2018-11-12 16:49:50 UTC (rev 238089)
@@ -660,8 +660,9 @@
         : CSSCalcExpressionNode(category, isIntegerResult(op, leftSide.get(), rightSide.get()))
         , m_operator(op)
     {
-        m_children.append(WTFMove(leftSide));
-        m_children.append(WTFMove(rightSide));
+        m_children.reserveInitialCapacity(2);
+        m_children.uncheckedAppend(WTFMove(leftSide));
+        m_children.uncheckedAppend(WTFMove(rightSide));
     }
 
     CSSCalcOperation(CalculationCategory category, CalcOperator op, Vector<Ref<CSSCalcExpressionNode>>&& children)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to