Suggested at Bug 103372. ContainerNode::replaceChild() calls multiple checkReplaceChild() for preventing manifold tree. But we can skip the one other than the first if we know there is no event listener fired since the last checkReplaceChild() call. That omission will improve replaceChild() performance.
Created attachment 176693 [details] Patch
I tried, but didn't go faster and went even slower. It looks our fast path does fast enough. I'd close this bug unless there are something I overlooked.
What did you use to measure performance here? The main performance bottleneck in checkAcceptChild I think is the contains call, which is O(n) in the depth of the tree. I would expect a test case with a deep tree to show improvement.
(In reply to comment #3) > What did you use to measure performance here? The main performance bottleneck in checkAcceptChild I think is the contains call, which is O(n) in the depth of the tree. I would expect a test case with a deep tree to show improvement. Ah, that's right. What I used is dom-modify. We need some better benchmark here.
(In reply to comment #4) > We need some better benchmark We're always saying this:D
(In reply to comment #5) > (In reply to comment #4) > > We need some better benchmark > > We're always saying this:D lol. It's always true! I don't think that the benchmarks we have generally don't test deep DOM trees, so we don't get good performance testing of things that are O(n) in DOM depth.