Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize more for the empty case #34

Merged
merged 5 commits into from
Aug 23, 2022
Merged

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
Owner

@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

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
@Gankra
Copy link
Owner

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 Gankra:main Aug 23, 2022
@Gankra
Copy link
Owner

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