Bug 250654
| Summary: | GraphicsLayer::removeAllChildren shouldn't be n^2 | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Ahmad Saleem <ahmad.saleem792> |
| Component: | Compositing | Assignee: | Chris Dumez <cdumez> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | cdumez, simon.fraser, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Ahmad Saleem
Hi Team,
Usually reducing expensive calls are always better, so I just wanted to raise and get input whether we can do similar to improve performance or reach to similar idea:
Blink Commit - https://chromium.googlesource.com/chromium/blink/+/ea1156d6f005f978e4da707ef4e2060c2fc7151f
WebKit GitHub - https://searchfox.org/wubkat/source/Source/WebCore/platform/graphics/GraphicsLayer.cpp#316 & https://searchfox.org/wubkat/source/Source/WebCore/platform/graphics/GraphicsLayer.cpp#395
Just wanted to raise so if it is something worth implementing with the same idea, we can gain some performance point.
Thanks!
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/104534645>
Ahmad Saleem
This compiles:
void GraphicsLayer::removeAllChildren()
{
while (!m_children.isEmpty()) {
auto curLayer = m_children.last();
...
_______________
NOTE - It seems 'removeFromParent' calls 'removeFromParentInternal()' and it seems to be using 'removeFirstMatching' rather than 'reverseFind' but don't know how to amend this part.
void GraphicsLayer::removeFromParentInternal()
{
if (m_parent) {
GraphicsLayer* parent = m_parent;
setParent(nullptr);
parent->m_children.removeFirstMatching([this](auto& layer) {
return layer.ptr() == this;
});
// |this| may be destroyed here.
}
}
______________
Chris Dumez
Pull request: https://github.com/WebKit/WebKit/pull/18578
EWS
Committed 268814@main (106c4aae5f43): <https://commits.webkit.org/268814@main>
Reviewed commits have been landed. Closing PR #18578 and removing active labels.