Skip to content

uint-spbset: reuse empty chunks - #22340

Closed
icing wants to merge 1 commit into
curl:masterfrom
icing:event-spbset-tweaks
Closed

uint-spbset: reuse empty chunks#22340
icing wants to merge 1 commit into
curl:masterfrom
icing:event-spbset-tweaks

Conversation

@icing

@icing icing commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Fix chunk allocations by reusing existing empty chunks when a new offset is needed. Before this fix, spbsets would only ever grow with added numbers outside the range of existing chunks.

Fix chunk allocations by reusing existing empty chunks when
a new offset is needed. Before this fix, spbsets would only
ever grow with added numbers outside the range of existing
chunks.
@icing icing changed the title uint-spbset: reused empty chunks uint-spbset: reuse empty chunks Jul 17, 2026
@icing
icing requested a review from bagder July 17, 2026 12:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the uint32_spbset sparse bitset implementation by reusing existing empty chunks when growing the set to cover a new offset, avoiding unnecessary allocations and preventing spbsets from only ever growing when values move across offset ranges.

Changes:

  • Add helpers to detect and detach reusable empty chunks, and to insert chunks into the ordered chunk list.
  • Update chunk lookup/creation to preferentially reuse empty chunks before allocating new ones.
  • Simplify per-chunk indexing arithmetic in add/remove/contains.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bagder bagder closed this in c5fd5eb Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants