[wpt-sync] Sync PR 41265 - Add append_to argument to Clone() to avoid extra InsertedInto calls
Categories
(Core :: DOM: Core & HTML, task, P4)
Tracking
()
Tracking | Status | |
---|---|---|
firefox118 | --- | fixed |
People
(Reporter: wpt-sync, Unassigned)
References
()
Details
(Whiteboard: [wptsync downstream])
Sync web-platform-tests PR 41265 into mozilla-central (this bug is closed when the sync is complete).
PR: https://github.com/web-platform-tests/wpt/pull/41265
Details from upstream follow.
Mason Freed <masonf@chromium.org> wrote:
Add append_to argument to Clone() to avoid extra InsertedInto calls
Because of the order of operations for Clone(), previous to this CL,
the typical sequence would be:
- Clone the element
- Clone the children of the element (recursing to step #1).
- AppendChild() each cloned child to its parent cloned element.
- (in the caller of Clone) AppendChild the cloned element to its
eventual parent.Because each AppendChild triggers a call to Node::InsertedInto() for
all descendants of the appended element [1], the fact that the tree
is constructed bottom-up (leaf nodes first) means that InsertedInto()
is called N^2 times, where N is the depth of the cloned tree.Because clone-and-append is a very common pattern, this CL adds an
append_to
argument toClone()
, which appends to the parent before
appending the children.This CL also adds a perf test for this scenario (cloning a deep tree).
Locally, on a debug build, this test gives 0.13 runs/s before this CL,
and 0.40 runs/s after, for a 3.1X speedup.Bug: 1453291
Change-Id: Icdd75c45aa5ecc4fe8bb5d1ff0b7a2b27bec2171
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://chromium-review.googlesource.com/4728983
WPT-Export-Revision: f09d0b0e757070fa10e9789d2d6438ba6c4c7d2e
Assignee | ||
Updated•1 year ago
|
Assignee | ||
Comment 1•1 year ago
|
||
Pushed to try (stability) https://treeherder.mozilla.org/#/jobs?repo=try&revision=489ae36d5910fc839018a5cc9696a2b9dbde4750
Assignee | ||
Comment 2•1 year ago
|
||
Test result changes from PR not available.
Pushed by ctuns@mozilla.com: https://hg.mozilla.org/mozilla-central/rev/1294fa7756a0 [wpt PR 41265] - Add append_to argument to Clone() to avoid extra InsertedInto calls, a=testonly
Comment 4•1 year ago
|
||
bugherder |
Description
•