Skip to content

Conversation

@nnethercote
Copy link
Contributor

These commits optimize several operations better for the case where the ThinVec is empty. This is a common case for my use case of interest (in rustc) and is likely a pretty common case for ThinVec in general. (More so than Vec, for example.) It does slightly pessimize the non-empty cases, but only to the tune of a single branch per operation, which is hopefully acceptable.

Copy link
Collaborator

@Gankra Gankra left a comment

Choose a reason for hiding this comment

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

seems good, just two nits

@Gankra
Copy link
Collaborator

Gankra commented Aug 23, 2022

Also there's something very funny about me having spent a fair amount of time carefully crafting code that works the same for the singleton and non-singleton case without UB and now you show up and go "actually it's faster to wrap everything in a fast-path guard against the singleton case" 🥲

@nnethercote
Copy link
Contributor Author

Ok, review comments addressed. Thanks for the fast review.

@Gankra Gankra merged commit 4253fb6 into mozilla:main Aug 23, 2022
@Gankra
Copy link
Collaborator

Gankra commented Aug 23, 2022

v0.2.8 published

@nnethercote nnethercote deleted the opt-for-empty-case branch August 23, 2022 22:16
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