]> git.lizzy.rs Git - rust.git/commitdiff
vec: Remove the Vec specialization for .extend()
authorUlrik Sverdrup <bluss@users.noreply.github.com>
Wed, 26 Oct 2016 22:40:09 +0000 (00:40 +0200)
committerUlrik Sverdrup <bluss@users.noreply.github.com>
Wed, 26 Oct 2016 23:45:31 +0000 (01:45 +0200)
This now produces as good code (with optimizations) using the TrustedLen
codepath.

src/libcollections/vec.rs

index c42926b09526c027f898a4267ce91893454a1b39..16331960cc198bed1259a231f590837e35f1238c 100644 (file)
@@ -76,7 +76,6 @@
 use core::ptr::Shared;
 use core::slice;
 
-use super::SpecExtend;
 use super::range::RangeArgument;
 
 /// A contiguous growable array type, written `Vec<T>` but pronounced 'vector.'
@@ -1554,22 +1553,10 @@ fn into_iter(mut self) -> slice::IterMut<'a, T> {
 impl<T> Extend<T> for Vec<T> {
     #[inline]
     fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
-        <Self as SpecExtend<I>>::spec_extend(self, iter);
-    }
-}
-
-impl<I: IntoIterator> SpecExtend<I> for Vec<I::Item> {
-    default fn spec_extend(&mut self, iter: I) {
         self.extend_desugared(iter.into_iter())
     }
 }
 
-impl<T> SpecExtend<Vec<T>> for Vec<T> {
-    fn spec_extend(&mut self, ref mut other: Vec<T>) {
-        self.append(other);
-    }
-}
-
 trait IsTrustedLen : Iterator {
     fn trusted_len(&self) -> Option<usize> { None }
 }