Specialization for Extend<&T> for vec #38182

Merged
merged 1 commit into from Dec 8, 2016

Projects

None yet

4 participants

@bluss
Contributor
bluss commented Dec 5, 2016

Specialize to use copy_from_slice when extending a Vec with &[T] where
T: Copy.

This specialization results in .clone() not being called in extend_from_slice and extend when the element is Copy.

Fixes #38021

@rust-highfive
Collaborator

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@bluss
Contributor
bluss commented Dec 5, 2016

r? @alexcrichton This fix goes forward instead of backwards, you could say, by adding more specializations instead of reverting.

@bluss bluss vec: More specialization for Extend<&T> for vec
Specialize to use copy_from_slice when extending a Vec with &[T] where
T: Copy.
02bf1ce
@alexcrichton
Member

@bors: r+

Seems ok to me, thanks!

I'd still ideally prefer to explore the route of adding codegen tests eventually (to ensure we don't regress) but that can happen in a follow-up

@bors
Contributor
bors commented Dec 6, 2016

📌 Commit 02bf1ce has been approved by alexcrichton

@bluss
Contributor
bluss commented Dec 6, 2016 edited

Ok, there is no codegen test, but codegen for extend_with_slice was examined and was fine before it went in, so in that way it's unlikely that it would have been caught that way. It already optimized fine in many situations.

@bluss
Contributor
bluss commented Dec 7, 2016 edited

@dtolnay This PR fixes the regression in the sense that the regression I saw here #38021 (comment) was verified to be back at its old performance at 1.5-1.6 ms/iter. I haven't done further tests.

@bors
Contributor
bors commented Dec 8, 2016

⌛️ Testing commit 02bf1ce with merge 7537f95...

@bors bors added a commit that referenced this pull request Dec 8, 2016
@bors bors Auto merge of #38182 - bluss:more-vec-extend, r=alexcrichton
Specialization for Extend<&T> for vec

Specialize to use copy_from_slice when extending a Vec with &[T] where
T: Copy.

This specialization results in `.clone()` not being called in `extend_from_slice` and `extend` when the element is `Copy`.

Fixes #38021
7537f95
@bors bors merged commit 02bf1ce into rust-lang:master Dec 8, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@bluss bluss deleted the bluss:more-vec-extend branch Dec 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment