Skip to content

Remove inaccurate hints. - #94

Merged
ltratt merged 1 commit into
softdevteam:masterfrom
ltratt:remove_hints
Aug 31, 2026
Merged

Remove inaccurate hints.#94
ltratt merged 1 commit into
softdevteam:masterfrom
ltratt:remove_hints

Conversation

@ltratt

@ltratt ltratt commented Aug 31, 2026

Copy link
Copy Markdown
Member

iter_set_bits and iter_unset_bits don't know -- unless one does count_set_bits how many bits they will yield. That means that size_hint on these two iterators returned the size of the entire Vob which is always >= the number of set/unset bits. If used in idioms along the lines of vob.iter_set_bits().collect() this could cause significant overallocation.

An open question is whether, in general, it's better to have size_hint call count_[un]set_bits. My guess is, in general, "no", but either way, for now the best thing to do is stop handing out misleading size hints.

`iter_set_bits` and `iter_unset_bits` don't know -- unless one does
`count_set_bits` - how many bits they will yield. That means that
`size_hint` on these two iterators returned the size of the entire Vob
which is always `>=` the number of set/unset bits. If used in idioms
along the lines of `vob.iter_set_bits().collect()` this could cause
significant overallocation.

An open question is whether, in general, it's better to have `size_hint`
call `count_[un]set_bits`. My guess is, in general, "no", but either
way, for now the best thing to do is stop handing out misleading size
hints.
@ltratt
ltratt enabled auto-merge August 31, 2026 09:03
@ltratt
ltratt added this pull request to the merge queue Aug 31, 2026
Merged via the queue into softdevteam:master with commit bb287e3 Aug 31, 2026
2 checks passed
@ltratt
ltratt deleted the remove_hints branch August 31, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant