diff options
| author | ljedrz <ljedrz@gmail.com> | 2018-07-30 14:54:33 +0200 |
|---|---|---|
| committer | ljedrz <ljedrz@gmail.com> | 2018-07-30 20:23:37 +0200 |
| commit | 9169934e27c955787e94186364dcc6fcb7455e4d (patch) | |
| tree | c53f08cef9aa1660c520d65b01a7554d39a1b419 /src/librustc_data_structures | |
| parent | a3f519df09bf40d09c1a111599b8f115f11fbb49 (diff) | |
| download | rust-9169934e27c955787e94186364dcc6fcb7455e4d.tar.gz rust-9169934e27c955787e94186364dcc6fcb7455e4d.zip | |
Use Vec::extend in SmallVec::extend when applicable
Diffstat (limited to 'src/librustc_data_structures')
| -rw-r--r-- | src/librustc_data_structures/small_vec.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/librustc_data_structures/small_vec.rs b/src/librustc_data_structures/small_vec.rs index 83eb54fade1..bfa580eb186 100644 --- a/src/librustc_data_structures/small_vec.rs +++ b/src/librustc_data_structures/small_vec.rs @@ -169,10 +169,18 @@ impl<A: Array> FromIterator<A::Element> for SmallVec<A> { impl<A: Array> Extend<A::Element> for SmallVec<A> { fn extend<I: IntoIterator<Item=A::Element>>(&mut self, iter: I) { - let iter = iter.into_iter(); - self.reserve(iter.size_hint().0); - for el in iter { - self.push(el); + if self.is_array() { + let iter = iter.into_iter(); + self.reserve(iter.size_hint().0); + + for el in iter { + self.push(el); + } + } else { + match self.0 { + AccumulateVec::Heap(ref mut vec) => vec.extend(iter), + _ => unreachable!() + } } } } |
