WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
43687
Web Inspector: speed-up Element.prototype.removeChildren
https://bugs.webkit.org/show_bug.cgi?id=43687
Summary
Web Inspector: speed-up Element.prototype.removeChildren
Nikita Vasilyev
Reported
2010-08-08 04:53:04 PDT
The current Element.prototype.removeChildren is using `element.innerHTML = ""`. It's the slowest method in my benchmarks:
http://jsperf.com/remove-all-child-nodes/2
(20x faster in WebKit, 35x in Chrome)
http://jsperf.com/remove-all-child-nodes-5-childs/3
(1,6 faster in WebKit, 2x in Chrome)
http://jsperf.com/remove-all-child-nodes-zero-childs
(1,6 faster in WebKit, 2x in Chrome)
Attachments
patch
(1.02 KB, patch)
2010-08-08 04:57 PDT
,
Nikita Vasilyev
pfeldman
: review-
Details
Formatted Diff
Diff
this.textContent = ""
(1006 bytes, patch)
2010-08-08 06:59 PDT
,
Nikita Vasilyev
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Nikita Vasilyev
Comment 1
2010-08-08 04:57:39 PDT
Created
attachment 63840
[details]
patch
Pavel Feldman
Comment 2
2010-08-08 05:11:36 PDT
Comment on
attachment 63840
[details]
patch In fact I've done the opposite optimization earlier:
https://bugs.webkit.org/show_bug.cgi?id=31160
Timeline was lagging visually on scrolling and clearing + shark was showing this to be the slow operation. I'd suggest that you try those. Wrt benchmarks, I think they lack listeners - adding those would change the WebKit picture a lot. I know that the bindings have improved, but still, single call to native will always be ways faster.
Nikita Vasilyev
Comment 3
2010-08-08 05:17:58 PDT
(In reply to
comment #2
)
> (From update of
attachment 63840
[details]
) > In fact I've done the opposite optimization earlier: >
https://bugs.webkit.org/show_bug.cgi?id=31160
> > Timeline was lagging visually on scrolling and clearing + shark was showing this to be the slow operation. I'd suggest that you try those. Wrt benchmarks, I think they lack listeners - adding those would change the WebKit picture a lot. I know that the bindings have improved, but still, single call to native will always be ways faster.
Oh, I didn't think about reflow. At this case `element.textContent = ""` would be faster. By the way, what are Wrt benchmarks?
Nikita Vasilyev
Comment 4
2010-08-08 06:59:23 PDT
Created
attachment 63842
[details]
this.textContent = ""
http://elv1s.ru/files/js/removeChildren.html
Now innerHTML and textContent works the same. removeFirstChild is a little slower. When inspecting the DOM, there are many calls of removeChildren while an element already doesn't have children. So I added `if (this.firstChild)` check.
Pavel Feldman
Comment 5
2010-08-08 09:29:15 PDT
Comment on
attachment 63842
[details]
this.textContent = "" Thanks for doing this!
Eric Seidel (no email)
Comment 6
2010-08-08 10:45:31 PDT
Comment on
attachment 63842
[details]
this.textContent = "" Clearing flags on attachment: 63842 Committed
r64952
: <
http://trac.webkit.org/changeset/64952
>
Eric Seidel (no email)
Comment 7
2010-08-08 10:45:37 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug