perf: Insertion-sort the sweep broadphase and swap-remove its active list - #3983
Merged
Conversation
This was referenced Aug 5, 2026
Open
spydon
force-pushed
the
perf/sweep-insertion-sort
branch
from
August 5, 2026 20:18
eacf83f to
ef353a5
Compare
luanpotter
reviewed
Aug 7, 2026
spydon
force-pushed
the
perf/sweep-insertion-sort
branch
from
August 16, 2026 13:25
ef353a5 to
a676a48
Compare
spydon
force-pushed
the
perf/sweep-insertion-sort
branch
from
August 16, 2026 15:05
1fe301b to
4dbea34
Compare
spydon
changed the base branch from
perf/pointer-handler-early-out
to
perf/removal-teardown-buffer
August 16, 2026 15:06
…sort # Conflicts: # packages/flame/lib/src/components/core/component.dart
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
Sweep.updatere-sorted its items with a fullList.sortand a closure comparator every tick, although the list is nearly sorted between ticks (hitboxes only move a little per frame); an insertion sort makes that near-linear.Sweep.queryalso pruned its active list with a searchingList.remove; since active-list order does not matter, that is now an O(1) swap-remove.Extracted from #3960 so the data-structure change there stands alone (as requested in this comment). Stacked on #3982.
Checklist
docsand added dartdoc comments with///.examplesordocs.Breaking Change?
Related Issues
Relates to #3957