Skip to content

Commit 4e64b64

Browse files
mfreed7chromium-wpt-export-bot
authored andcommitted
Optimize several things about DOM Parts [2/2]
This CL continues the optimization work, with these changes: - Replace ClonePartsFrom() with PartRoot::CloneParts(), to centralize the part cloning functionality into a single place. - Replace NodeCloningData's HeapHashMap architecture with a much simpler stack architecture. Also eliminate the cloning part queue, and replace it with a clone-as-you-go approach. With this new system, as a Node containing Parts is cloned, the Parts are iterated and cloned, validating them with IsValid first. As ChildNodeParts are encountered, they are cloned with both sibling nodes pointing to the same node, and the new ChildNodePart is pushed onto the part root stack. As the next_sibling is encountered, the ChildNodePart is updated to have the correct sibling node, and the part root stack is popped. All of this together achieves the same behavior, but with much lower speed cost. - Part::IsValid() is cached to improve speed, and disconnected_ becomes connected_ to avoid a `!`. - PartRoot's cached parts list is converted from a Deque to a HeapVector, which is more efficient. That eliminates the ability to modify the front of the list, so this will adversely impact performance for some operations when DOMPartsAPIActivePartTracking is enabled (off by default). Bug: 1453291 Change-Id: I2a2025dd4d1e0c1fa4c85a21469526f6ff1f86d6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4909445 Reviewed-by: Joey Arhar <[email protected]> Commit-Queue: Mason Freed <[email protected]> Auto-Submit: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1205329}
1 parent 161e1f9 commit 4e64b64

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

dom/parts/basic-dom-part-objects.tentative.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120

121121
// Test cloning of the entire DocumentPartRoot.
122122
const clonedPartRoot = root.clone();
123+
assertEqualParts(root.getParts(),rootExpectations,[nodePart,childNodePart],'cloning a part root should not change the original');
123124
const clonedContainer = clonedPartRoot.rootContainer;
124125
assert_true(clonedPartRoot instanceof DocumentPartRoot);
125126
assert_true(clonedContainer instanceof (useTemplate ? DocumentFragment : Document));

0 commit comments

Comments
 (0)