Skip to content

Specialize Vec::clone_from for Copy types #87913

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 2 commits into from
Aug 14, 2021

Conversation

a1phyr
Copy link
Contributor

@a1phyr a1phyr commented Aug 10, 2021

This should improve performance and reduce code size.

This also improves clone_from for String, OsString and PathBuf.

This should improve performance and reduce code size.

This also improves `clone_from` for `String`, `OsString` and `PathBuf`.
@rust-highfive
Copy link
Contributor

r? @dtolnay

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 10, 2021
@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Looks good. SpecCloneFrom needs to be feature gated on not(no_global_oom_handling) though to fix the failed build.

error[E0599]: no method named `extend_from_slice` found for mutable reference `&mut Vec<T, A>` in the current scope

This should improve performance and reduce code size.

Would you be able to put together a microbenchmark measuring either of these things?

@a1phyr
Copy link
Contributor Author

a1phyr commented Aug 12, 2021

Here is a godbolt link for comparison: https://rust.godbolt.org/z/6oGTYs9Ys

Specialization removes a branch and a memcpy call.

@dtolnay
Copy link
Member

dtolnay commented Aug 14, 2021

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 14, 2021

📌 Commit 94d6b22 has been approved by dtolnay

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 14, 2021
@bors
Copy link
Collaborator

bors commented Aug 14, 2021

⌛ Testing commit 94d6b22 with merge a59e885...

@bors
Copy link
Collaborator

bors commented Aug 14, 2021

☀️ Test successful - checks-actions
Approved by: dtolnay
Pushing a59e885 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 14, 2021
@bors bors merged commit a59e885 into rust-lang:master Aug 14, 2021
@rustbot rustbot added this to the 1.56.0 milestone Aug 14, 2021
@a1phyr a1phyr deleted the vec_spec_clone_from branch March 12, 2024 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants