Changeset 116677 in webkit
- Timestamp:
- May 10, 2012 12:52:05 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r116675 r116677 1 2012-05-10 Antti Koivisto <antti@apple.com> 2 3 Inline Node::traverseNextNode 4 https://bugs.webkit.org/show_bug.cgi?id=85844 5 6 Reviewed by Ryosuke Niwa. 7 8 Inline traverseNextNode and traverseNextSibling to reduce entry/exit overhead and allow better code generation 9 for many hot loops. 10 11 In this version only the firstChild()/nextSibling() tests are inlined and the ancestor traversal is not. 12 13 Performance bots will tell if this was worthwhile. 14 15 * dom/ContainerNode.h: 16 (WebCore::Node::traverseNextNode): 17 (WebCore): 18 (WebCore::Node::traverseNextSibling): 19 * dom/Node.cpp: 20 (WebCore::Node::traverseNextAncestorSibling): 21 * dom/Node.h: 22 (Node): 23 1 24 2012-05-10 Tommy Widenflycht <tommyw@google.com> 2 25 -
trunk/Source/WebCore/WebCore.exp.in
r116549 r116677 2100 2100 __ZN7WebCore8Document22setAnimatingFullScreenEb 2101 2101 __ZNK7WebCore8Document9domWindowEv 2102 __ZNK7WebCore4Node 16traverseNextNodeEPKS0_2102 __ZNK7WebCore4Node27traverseNextAncestorSiblingEv 2103 2103 #endif 2104 2104 -
trunk/Source/WebCore/dom/ContainerNode.h
r116629 r116677 230 230 } 231 231 232 inline Node* Node::traverseNextSibling() const 233 { 234 if (nextSibling()) 235 return nextSibling(); 236 return traverseNextAncestorSibling(); 237 } 238 239 inline Node* Node::traverseNextNode() const 240 { 241 if (firstChild()) 242 return firstChild(); 243 return traverseNextSibling(); 244 } 245 246 inline Node* Node::traverseNextSibling(const Node* stayWithin) const 247 { 248 if (this == stayWithin) 249 return 0; 250 if (nextSibling()) 251 return nextSibling(); 252 return traverseNextAncestorSibling(stayWithin); 253 } 254 255 inline Node* Node::traverseNextNode(const Node* stayWithin) const 256 { 257 if (firstChild()) 258 return firstChild(); 259 return traverseNextSibling(stayWithin); 260 } 261 232 262 typedef Vector<RefPtr<Node>, 11> NodeVector; 233 263 -
trunk/Source/WebCore/dom/Node.cpp
r116644 r116677 1089 1089 } 1090 1090 1091 Node* Node::traverseNextNode(const Node* stayWithin) const 1092 { 1093 if (firstChild()) 1094 return firstChild(); 1095 if (this == stayWithin) 1096 return 0; 1097 if (nextSibling()) 1098 return nextSibling(); 1099 const Node *n = this; 1100 while (n && !n->nextSibling() && (!stayWithin || n->parentNode() != stayWithin)) 1101 n = n->parentNode(); 1102 if (n) 1103 return n->nextSibling(); 1091 Node* Node::traverseNextAncestorSibling() const 1092 { 1093 ASSERT(!nextSibling()); 1094 for (const Node* node = parentNode(); node; node = node->parentNode()) { 1095 if (node->nextSibling()) 1096 return node->nextSibling(); 1097 } 1104 1098 return 0; 1105 1099 } 1106 1100 1107 Node* Node::traverseNextSibling(const Node* stayWithin) const 1108 { 1109 if (this == stayWithin) 1110 return 0; 1111 if (nextSibling()) 1112 return nextSibling(); 1113 const Node *n = this; 1114 while (n && !n->nextSibling() && (!stayWithin || n->parentNode() != stayWithin)) 1115 n = n->parentNode(); 1116 if (n) 1117 return n->nextSibling(); 1101 Node* Node::traverseNextAncestorSibling(const Node* stayWithin) const 1102 { 1103 ASSERT(!nextSibling()); 1104 ASSERT(this != stayWithin); 1105 for (const Node* node = parentNode(); node; node = node->parentNode()) { 1106 if (node == stayWithin) 1107 return 0; 1108 if (node->nextSibling()) 1109 return node->nextSibling(); 1110 } 1118 1111 return 0; 1119 1112 } -
trunk/Source/WebCore/dom/Node.h
r116644 r116677 432 432 // argument is non-null, the traversal will stop once the specified node is reached. 433 433 // This can be used to restrict traversal to a particular sub-tree. 434 Node* traverseNextNode(const Node* stayWithin = 0) const; 434 Node* traverseNextNode() const; 435 Node* traverseNextNode(const Node* stayWithin) const; 435 436 436 437 // Like traverseNextNode, but skips children and starts with the next sibling. 437 Node* traverseNextSibling(const Node* stayWithin = 0) const; 438 Node* traverseNextSibling() const; 439 Node* traverseNextSibling(const Node* stayWithin) const; 438 440 439 441 // Does a reverse pre-order traversal to find the node that comes before the current one in document order … … 768 770 Element* ancestorElement() const; 769 771 772 Node* traverseNextAncestorSibling() const; 773 Node* traverseNextAncestorSibling(const Node* stayWithin) const; 774 770 775 // Use Node::parentNode as the consistent way of querying a parent node. 771 776 // This method is made private to ensure a compiler error on call sites that
Note: See TracChangeset
for help on using the changeset viewer.