Skip to content

Avoid .clear() in ArrayVec Drop if T doesn't need to drop - #330

Merged
bluss merged 1 commit into
bluss:masterfrom
barakugav:needs-drop
Nov 20, 2026
Merged

bluss merged 1 commit into
bluss:masterfrom
barakugav:needs-drop

Conversation

@barakugav

@barakugav barakugav commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

before the PR, a Drop of ArrayVec still did some work even if T doesn't need to drop: it did self.set_len(0) which LLVM didnt optimize.
In my use case, I use ArrayVec in many functions with lots of generics and skipping this set_len reduce my binary size by 4K.
I assume this can also affect performance in some extreme cases, but i didnt (try to) measure it. It saves 3 instructions on my mac.

thanks for the support, love the library! ❤️

@bluss

bluss commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Thanks for the measurements and the change!

I need to make a release, do poke me if it's not done within a week.

@bluss
bluss merged commit 816e677 into bluss:master Nov 20, 2026
7 checks passed
@barakugav
barakugav deleted the needs-drop branch November 20, 2026 17:23
@barakugav

Copy link
Copy Markdown
Contributor Author

@bluss thanks!
If you think it's fine to increase the msrv for the upcoming release, #314 can give users some serious gains and it will be great to include it

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.

2 participants