thin-vec icon indicating copy to clipboard operation
thin-vec copied to clipboard

Feature: unsafe push_unchecked

Open trueb2 opened this issue 1 year ago • 2 comments

I have a µcontroller that suffers with the push's including a branch on the len check (no branch predictor). I would like to reserve sufficient space, then push unchecked to avoid the overhead. I could similarly accomplish my goals with a spare_capacity_mut interface similar to Vec, but that provides slightly different internal data structure control rather than pushing initialized values through a more normal interface.

An Extend interface could benefit from this as well because it uses push internally. The Extend impl change would not resolve my purpose because it would require the overhead of managing state within the Iterator instance, so a pub push_unchecked would be preferred for me.

Would you be open to a PR with an unsafe push_unchecked impl?

trueb2 avatar Jul 26 '24 14:07 trueb2