Skip to content

Optimize clone and extend #33

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

Merged
merged 3 commits into from
Aug 19, 2022
Merged

Conversation

nnethercote
Copy link
Contributor

Some small performance wins I found while integrating ThinVec into rustc.

When `thin-vec` is included in rustc via "path" rather than via "version",
these warnings occur. They are all part of the `rust_2018_idioms` lint.
I don't really understand why they occur, but fixing them seems
harmless?
`Vec::extend` is likewise inlined.
@nnethercote
Copy link
Contributor Author

Best reviewed one commit at a time.

Currently it reserves capacity using `with_capacity`. It then calls
`extend`, which (unnecessarily) calls `reserve`. It then calls `push` N
times, each of which (unnecessarily) does a capacity check.
@nnethercote nnethercote force-pushed the opt-clone-and-extend branch from 9a72ec1 to 6780695 Compare August 19, 2022 04:47
@Gankra Gankra merged commit f23417b into Gankra:main Aug 19, 2022
@Gankra
Copy link
Owner

Gankra commented Aug 19, 2022

Thanks!

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