Skip to content

Extend Performance Optimization #21

@orxfun

Description

@orxfun

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions