Avoid unnecessarily padding the FontDescription families vector.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Nov 2013 11:45:47 +0000 (11:45 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Nov 2013 11:45:47 +0000 (11:45 +0000)
<https://webkit.org/b/124267>

Use a bit of reserveInitialCapacity+uncheckedAppend grease to avoid
jumping all the way to capacity=16 when a style has more than just
a single font-family in it.

130 kB progression on HTML5-8266 locally.

Reviewed by Antti Koivisto.

* css/DeprecatedStyleBuilder.cpp:
(WebCore::ApplyPropertyFontFamily::applyValue):

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

Source/WebCore/ChangeLog
Source/WebCore/css/DeprecatedStyleBuilder.cpp

index 9138e13..1689a0f 100644 (file)
@@ -1,5 +1,21 @@
 2013-11-13  Andreas Kling  <akling@apple.com>
 
+        Avoid unnecessarily padding the FontDescription families vector.
+        <https://webkit.org/b/124267>
+
+        Use a bit of reserveInitialCapacity+uncheckedAppend grease to avoid
+        jumping all the way to capacity=16 when a style has more than just
+        a single font-family in it.
+
+        130 kB progression on HTML5-8266 locally.
+
+        Reviewed by Antti Koivisto.
+
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::ApplyPropertyFontFamily::applyValue):
+
+2013-11-13  Andreas Kling  <akling@apple.com>
+
         Make remaining CSSPrimitiveValue constructors return PassRef.
         <https://webkit.org/b/124270>
 
index 1bdee73..99a75aa 100644 (file)
@@ -703,14 +703,18 @@ public:
         if (!value->isValueList())
             return;
 
+        auto& valueList = toCSSValueList(*value);
+
         FontDescription fontDescription = styleResolver->style()->fontDescription();
         // Before mapping in a new font-family property, we should reset the generic family.
         bool oldFamilyUsedFixedDefaultSize = fontDescription.useFixedDefaultSize();
         fontDescription.setGenericFamily(FontDescription::NoFamily);
 
         Vector<AtomicString, 1> families;
-        for (CSSValueListIterator i = value; i.hasMore(); i.advance()) {
-            CSSValue* item = i.value();
+        families.reserveInitialCapacity(valueList.length());
+
+        for (unsigned i = 0; i < valueList.length(); ++i) {
+            CSSValue* item = valueList.item(i);
             if (!item->isPrimitiveValue())
                 continue;
             CSSPrimitiveValue* contentValue = toCSSPrimitiveValue(item);
@@ -755,7 +759,7 @@ public:
                 continue;
             if (families.isEmpty())
                 fontDescription.setIsSpecifiedFont(fontDescription.genericFamily() == FontDescription::NoFamily);
-            families.append(face);
+            families.uncheckedAppend(face);
         }
 
         if (families.isEmpty())