Skip to content

Conversation

@pull
Copy link

@pull pull bot commented Jan 21, 2026

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

mischnic and others added 3 commits January 21, 2026 09:35
### What?

Use amortized shrinking.

Capacity should always be a power of 2.
We shrink when len is capacity / 3.
Assuming the capacity was `2^x` we shrink to `2^(x-1)` which is
`capacity / 2`.
Therefore capacity is still larger than len, which avoids direct
reallocation when items are added again.
@pull pull bot locked and limited conversation to collaborators Jan 21, 2026
@pull pull bot added the ⤵️ pull label Jan 21, 2026
@pull pull bot merged commit d5d7605 into code:canary Jan 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants