Title: [125009] trunk/Source/WebCore
Revision
125009
Author
hara...@chromium.org
Date
2012-08-08 01:43:22 -0700 (Wed, 08 Aug 2012)

Log Message

Optimize Element::hasAttribute() by replacing String with AtomicString
https://bugs.webkit.org/show_bug.cgi?id=90273

Reviewed by Adam Barth.

Based on the observation described in this ChangeLog
(http://trac.webkit.org/changeset/121439), this patch optimizes the
performance of Element::hasAttribute() by replacing String with AtomicString.

Performance test: https://bugs.webkit.org/attachment.cgi?id=150144

hasAttribute (Chromium/Linux):
329.60ms => 259.00ms

hasAttributeNS (Chromium/Linux):
549.60ms => 435.80ms

* dom/Element.cpp:
(WebCore::Element::hasAttribute):
(WebCore::Element::hasAttributeNS):
* dom/Element.h:
(Element):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (125008 => 125009)


--- trunk/Source/WebCore/ChangeLog	2012-08-08 08:24:44 UTC (rev 125008)
+++ trunk/Source/WebCore/ChangeLog	2012-08-08 08:43:22 UTC (rev 125009)
@@ -1,5 +1,30 @@
 2012-08-08  Kentaro Hara  <hara...@chromium.org>
 
+        Optimize Element::hasAttribute() by replacing String with AtomicString
+        https://bugs.webkit.org/show_bug.cgi?id=90273
+
+        Reviewed by Adam Barth.
+
+        Based on the observation described in this ChangeLog
+        (http://trac.webkit.org/changeset/121439), this patch optimizes the
+        performance of Element::hasAttribute() by replacing String with AtomicString.
+
+        Performance test: https://bugs.webkit.org/attachment.cgi?id=150144
+
+        hasAttribute (Chromium/Linux):
+        329.60ms => 259.00ms
+
+        hasAttributeNS (Chromium/Linux):
+        549.60ms => 435.80ms
+
+        * dom/Element.cpp:
+        (WebCore::Element::hasAttribute):
+        (WebCore::Element::hasAttributeNS):
+        * dom/Element.h:
+        (Element):
+
+2012-08-08  Kentaro Hara  <hara...@chromium.org>
+
         Optimize Element::removeAttribute() by replacing String with AtomicString
         https://bugs.webkit.org/show_bug.cgi?id=90265
 

Modified: trunk/Source/WebCore/dom/Element.cpp (125008 => 125009)


--- trunk/Source/WebCore/dom/Element.cpp	2012-08-08 08:24:44 UTC (rev 125008)
+++ trunk/Source/WebCore/dom/Element.cpp	2012-08-08 08:43:22 UTC (rev 125009)
@@ -1524,18 +1524,18 @@
     return attributeData->getAttributeNode(QualifiedName(nullAtom, localName, namespaceURI), this);
 }
 
-bool Element::hasAttribute(const String& name) const
+bool Element::hasAttribute(const AtomicString& name) const
 {
     if (!attributeData())
         return false;
 
     // This call to String::lower() seems to be required but
     // there may be a way to remove it.
-    String localName = shouldIgnoreAttributeCase(this) ? name.lower() : name;
+    AtomicString localName = shouldIgnoreAttributeCase(this) ? name.lower() : name;
     return updatedAttributeData()->getAttributeItem(localName, false);
 }
 
-bool Element::hasAttributeNS(const String& namespaceURI, const String& localName) const
+bool Element::hasAttributeNS(const AtomicString& namespaceURI, const AtomicString& localName) const
 {
     const ElementAttributeData* attributeData = updatedAttributeData();
     if (!attributeData)

Modified: trunk/Source/WebCore/dom/Element.h (125008 => 125009)


--- trunk/Source/WebCore/dom/Element.h	2012-08-08 08:24:44 UTC (rev 125008)
+++ trunk/Source/WebCore/dom/Element.h	2012-08-08 08:43:22 UTC (rev 125009)
@@ -141,8 +141,8 @@
     // in style attribute or one of the SVG animation attributes.
     bool hasAttributesWithoutUpdate() const;
 
-    bool hasAttribute(const String& name) const;
-    bool hasAttributeNS(const String& namespaceURI, const String& localName) const;
+    bool hasAttribute(const AtomicString& name) const;
+    bool hasAttributeNS(const AtomicString& namespaceURI, const AtomicString& localName) const;
 
     const AtomicString& getAttribute(const AtomicString& name) const;
     const AtomicString& getAttributeNS(const AtomicString& namespaceURI, const AtomicString& localName) const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to