replace unsafe ptr::write with deref-write, benchmarks show no difference

This commit is contained in:
The8472
2020-01-25 15:01:39 +01:00
parent 9596e5a2f2
commit 0d2d033415
+4 -10
View File
@@ -2086,11 +2086,8 @@ fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
<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
let other = SpecFrom::from_iter(iter.into_iter());
// replace self, don't run drop since self was empty
unsafe {
ptr::write(self, other);
}
// and overwrite self
*self = SpecFrom::from_iter(iter.into_iter());
}
}
@@ -2544,11 +2541,8 @@ fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I) {
self.spec_extend(iter.into_iter())
} else {
// if self has no allocation then use the more powerful from_iter specializations
let other = SpecFrom::from_iter(iter.into_iter());
// replace self, don't run drop since self was empty
unsafe {
ptr::write(self, other);
}
// and overwrite self
*self = SpecFrom::from_iter(iter.into_iter());
}
}