Changeset 101967 in webkit
- Timestamp:
- Dec 4, 2011 1:52:56 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r101959 r101967 1 2011-12-04 Ryosuke Niwa <rniwa@webkit.org> 2 3 HIERARCHY_REQUEST_ERR check in checkAcceptChild should be optimized for newChild without children 4 https://bugs.webkit.org/show_bug.cgi?id=73737 5 6 Reviewed by Darin Adler. 7 8 It turned out that 50-70% of nodes inserted by DOM APIs such as insertBefore and appendChild 9 don't have any descendent nodes. Optimize isDescendantOf which is used by checkAcceptChild for this case. 10 On a test case attached on the bug, we see a 40% improvement. 11 12 Also optimize for cases where either new child or new parent but not both are in document as suggested 13 by Erik Arvidsson. This appears to happen about 40-70% of the time, and the symmetric difference between 14 the two cases is about 50% so it's worth implementing both optimizations. 15 16 Unfortunately no tests because we still have a O(n) algorithm somewhere. 17 18 * dom/Node.cpp: 19 (WebCore::Node::isDescendantOf): 20 (WebCore::Node::contains): 21 1 22 2011-12-04 Andreas Kling <kling@webkit.org> 2 23 -
trunk/Source/WebCore/dom/Node.cpp
r101144 r101967 1349 1349 { 1350 1350 // Return true if other is an ancestor of this, otherwise false 1351 if (!other) 1352 return false; 1351 if (!other || !other->firstChild() || inDocument() != other->inDocument()) 1352 return false; 1353 if (other == other->document()) 1354 return document() == other && this != document() && inDocument(); 1353 1355 for (const ContainerNode* n = parentNode(); n; n = n->parentNode()) { 1354 1356 if (n == other) … … 1362 1364 if (!node) 1363 1365 return false; 1364 if (document() == this)1365 return node->document() == this && node->inDocument();1366 1366 return this == node || node->isDescendantOf(this); 1367 1367 }
Note: See TracChangeset
for help on using the changeset viewer.