summary refs log tree commit diff
path: root/library/alloc/src
diff options
context:
space:
mode:
authorThe8472 <git@infinite-source.de>2020-08-26 23:24:34 +0200
committerThe8472 <git@infinite-source.de>2020-09-03 20:59:35 +0200
commit435219dd82896e9576ef3f7fbc5c2cf17bae0016 (patch)
treecc016d32f32ea6d40689d7afebf36f8c67e74221 /library/alloc/src
parent7492f76f777d2815290d3b8590dc3911df6336de (diff)
downloadrust-435219dd82896e9576ef3f7fbc5c2cf17bae0016.tar.gz
rust-435219dd82896e9576ef3f7fbc5c2cf17bae0016.zip
remove empty Vec extend optimization
The optimization meant that every extend code path had to emit llvm
IR for from_iter and extend spec_extend, which likely impacts
compile times while only improving a few edge-cases
Diffstat (limited to 'library/alloc/src')
-rw-r--r--library/alloc/src/vec.rs16
1 files changed, 2 insertions, 14 deletions
diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs
index dcfd3ecb3d3..2a778e1470d 100644
--- a/library/alloc/src/vec.rs
+++ b/library/alloc/src/vec.rs
@@ -2082,13 +2082,7 @@ impl<'a, T> IntoIterator for &'a mut Vec<T> {
 impl<T> Extend<T> for Vec<T> {
     #[inline]
     fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
-        if self.capacity() > 0 {
-            <Self as SpecExtend<T, I::IntoIter>>::spec_extend(self, iter.into_iter())
-        } else {
-            // if self has no allocation then use the more powerful from_iter specializations
-            // and overwrite self
-            *self = SpecFrom::from_iter(iter.into_iter());
-        }
+        <Self as SpecExtend<T, I::IntoIter>>::spec_extend(self, iter.into_iter())
     }
 
     #[inline]
@@ -2544,13 +2538,7 @@ impl<T> Vec<T> {
 #[stable(feature = "extend_ref", since = "1.2.0")]
 impl<'a, T: 'a + Copy> Extend<&'a T> for Vec<T> {
     fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I) {
-        if self.capacity() > 0 {
-            self.spec_extend(iter.into_iter())
-        } else {
-            // if self has no allocation then use the more powerful from_iter specializations
-            // and overwrite self
-            *self = SpecFrom::from_iter(iter.into_iter());
-        }
+        self.spec_extend(iter.into_iter())
     }
 
     #[inline]