Current Extend implementation of the SplitVec is only for convenience rather than for performance. The implementation looks as below
impl<T, G> Extend<T> for SplitVec<T, G>
where
G: Growth,
{
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
for x in iter {
self.push(x);
}
}
}
std::vec::Vec implementation, however, uses is optimized with special extend traits. With some book keeping and with the use of size hints, SplitVec can directly call std::vec::Vec::extend method and indirectly utilize these optimizations rather than pushing each element one after the other.
Current
Extend
implementation of theSplitVec
is only for convenience rather than for performance. The implementation looks as belowstd::vec::Vec
implementation, however, uses is optimized with special extend traits. With some book keeping and with the use of size hints,SplitVec
can directly callstd::vec::Vec::extend
method and indirectly utilize these optimizations rather than pushing each element one after the other.