Title: [179917] trunk/Source/WebCore
Revision
179917
Author
[email protected]
Date
2015-02-10 22:02:40 -0800 (Tue, 10 Feb 2015)

Log Message

Optimize MutableStyleProperties::removePropertiesInSet()
https://bugs.webkit.org/show_bug.cgi?id=141460

Reviewed by Andreas Kling.

Optimize MutableStyleProperties::removePropertiesInSet() by doing an
in-place removal of the vector properties, using the new and efficient
Vector::removalAllMatching().

I see a ~11% speed-up on CSS/CSSPropertySetterGetter.html performance
test.

This change was inspired by the following Blink revision:
https://src.chromium.org/viewvc/blink?view=rev&revision=189387

Test: PerformanceTests/CSS/CSSPropertySetterGetter.html

* css/StyleProperties.cpp:
(WebCore::MutableStyleProperties::removePropertiesInSet):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (179916 => 179917)


--- trunk/Source/WebCore/ChangeLog	2015-02-11 05:48:18 UTC (rev 179916)
+++ trunk/Source/WebCore/ChangeLog	2015-02-11 06:02:40 UTC (rev 179917)
@@ -1,3 +1,25 @@
+2015-02-10  Chris Dumez  <[email protected]>
+
+        Optimize MutableStyleProperties::removePropertiesInSet()
+        https://bugs.webkit.org/show_bug.cgi?id=141460
+
+        Reviewed by Andreas Kling.
+
+        Optimize MutableStyleProperties::removePropertiesInSet() by doing an
+        in-place removal of the vector properties, using the new and efficient
+        Vector::removalAllMatching().
+
+        I see a ~11% speed-up on CSS/CSSPropertySetterGetter.html performance
+        test.
+
+        This change was inspired by the following Blink revision:
+        https://src.chromium.org/viewvc/blink?view=rev&revision=189387
+
+        Test: PerformanceTests/CSS/CSSPropertySetterGetter.html
+
+        * css/StyleProperties.cpp:
+        (WebCore::MutableStyleProperties::removePropertiesInSet):
+
 2015-02-10  Alex Christensen  <[email protected]>
 
         [Win] Fix debug build after r179807.

Modified: trunk/Source/WebCore/css/StyleProperties.cpp (179916 => 179917)


--- trunk/Source/WebCore/css/StyleProperties.cpp	2015-02-11 05:48:18 UTC (rev 179916)
+++ trunk/Source/WebCore/css/StyleProperties.cpp	2015-02-11 06:02:40 UTC (rev 179917)
@@ -1133,23 +1133,10 @@
     for (unsigned i = 0; i < length; ++i)
         toRemove.add(set[i]);
 
-    Vector<CSSProperty> newProperties;
-    newProperties.reserveInitialCapacity(m_propertyVector.size());
-
-    unsigned size = m_propertyVector.size();
-    for (unsigned n = 0; n < size; ++n) {
-        const CSSProperty& property = m_propertyVector.at(n);
+    return m_propertyVector.removeAllMatching([&toRemove] (const CSSProperty& property) {
         // Not quite sure if the isImportant test is needed but it matches the existing behavior.
-        if (!property.isImportant()) {
-            if (toRemove.contains(property.id()))
-                continue;
-        }
-        newProperties.append(property);
-    }
-
-    bool changed = newProperties.size() != m_propertyVector.size();
-    m_propertyVector = newProperties;
-    return changed;
+        return !property.isImportant() && toRemove.contains(property.id());
+    }) > 0;
 }
 
 int ImmutableStyleProperties::findPropertyIndex(CSSPropertyID propertyID) const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to