perf: Replace generator-based removal teardown with an explicit collection pass - #3981
Open
spydon wants to merge 1 commit into
Open
perf: Replace generator-based removal teardown with an explicit collection pass#3981spydon wants to merge 1 commit into
spydon wants to merge 1 commit into
Conversation
This was referenced Aug 5, 2026
spydon
force-pushed
the
perf/removal-teardown-buffer
branch
from
August 5, 2026 20:18
4276a39 to
237d786
Compare
luanpotter
reviewed
Aug 7, 2026
| }, | ||
| includeSelf: true, | ||
| ); | ||
| final buffer = _teardownBuffer.isEmpty ? _teardownBuffer : <Component>[]; |
Member
There was a problem hiding this comment.
is allocating one empty list per component removal that significant? feels like this static cache is introducing potential future concurrency problems or hard to find headaches. seems that major gain here is the non-generator teardown and not the brittle [] cache?
luanpotter
reviewed
Aug 7, 2026
| ); | ||
| final buffer = _teardownBuffer.isEmpty ? _teardownBuffer : <Component>[]; | ||
| _collectTeardown(buffer); | ||
| for (var i = 0; i < buffer.length; i++) { |
Member
There was a problem hiding this comment.
please don't say that dart's built-in for each has some hidden performance cost too 😵💫
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The removal teardown walked the subtree through the recursive
descendantssync* generator, allocating generator frames per tree level on every component removal. It now collects the subtree into a reusable buffer (same leaves-first order) and iterates that.Extracted from #3960 so the data-structure change there stands alone (as requested in this comment). Stacked on #3980.
Checklist
docsand added dartdoc comments with///.examplesordocs.Breaking Change?
Related Issues
Relates to #3957