Title: [118199] trunk/Source/WebCore
Revision
118199
Author
da...@apple.com
Date
2012-05-23 10:33:06 -0700 (Wed, 23 May 2012)

Log Message

Speed up traverseNextNode when called on a ContainerNode or Element
https://bugs.webkit.org/show_bug.cgi?id=87224

Reviewed by Geoffrey Garen.

* dom/ContainerNode.h: Added overrides of traverseNextNode for ContainerNode.
That way, when we know at compile time something is ContainerNode, we can
skip a branch at the start of this hot function.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (118198 => 118199)


--- trunk/Source/WebCore/ChangeLog	2012-05-23 17:32:29 UTC (rev 118198)
+++ trunk/Source/WebCore/ChangeLog	2012-05-23 17:33:06 UTC (rev 118199)
@@ -1,3 +1,14 @@
+2012-05-23  Darin Adler  <da...@apple.com>
+
+        Speed up traverseNextNode when called on a ContainerNode or Element
+        https://bugs.webkit.org/show_bug.cgi?id=87224
+
+        Reviewed by Geoffrey Garen.
+
+        * dom/ContainerNode.h: Added overrides of traverseNextNode for ContainerNode.
+        That way, when we know at compile time something is ContainerNode, we can
+        skip a branch at the start of this hot function.
+
 2012-05-23  Sudarsana Nagineni  <sudarsana.nagin...@linux.intel.com>
 
         Use PluginDataNone.cpp always when NETSCAPE_PLUGIN_API is OFF

Modified: trunk/Source/WebCore/dom/ContainerNode.h (118198 => 118199)


--- trunk/Source/WebCore/dom/ContainerNode.h	2012-05-23 17:32:29 UTC (rev 118198)
+++ trunk/Source/WebCore/dom/ContainerNode.h	2012-05-23 17:33:06 UTC (rev 118199)
@@ -95,6 +95,10 @@
 
     void disconnectDescendantFrames();
 
+    // More efficient versions of these two functions for the case where we are starting with a ContainerNode.
+    Node* traverseNextNode() const;
+    Node* traverseNextNode(const Node* stayWithin) const;
+
 protected:
     ContainerNode(Document*, ConstructionType = CreateContainer);
 
@@ -243,6 +247,15 @@
     return traverseNextSibling();
 }
 
+inline Node* ContainerNode::traverseNextNode() const
+{
+    // More efficient than the Node::traverseNextNode above, because
+    // this does not need to do the isContainerNode check inside firstChild.
+    if (firstChild())
+        return firstChild();
+    return traverseNextSibling();
+}
+
 inline Node* Node::traverseNextSibling(const Node* stayWithin) const
 {
     if (this == stayWithin)
@@ -259,6 +272,15 @@
     return traverseNextSibling(stayWithin);
 }
 
+inline Node* ContainerNode::traverseNextNode(const Node* stayWithin) const
+{
+    // More efficient than the Node::traverseNextNode above, because
+    // this does not need to do the isContainerNode check inside firstChild.
+    if (firstChild())
+        return firstChild();
+    return traverseNextSibling(stayWithin);
+}
+
 typedef Vector<RefPtr<Node>, 11> NodeVector;
 
 inline void getChildNodes(Node* node, NodeVector& nodes)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to