-
Notifications
You must be signed in to change notification settings - Fork 13.4k
std::vec: Sane implementations for connect_vec and concat_vec #9583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Can we remove all the free functions |
Yes, remove them. |
impl<'self, T:Clone> VectorVector<T> for &'self [~[T]] { | ||
/// Flattens a vector of slices of T into a single vector of T. | ||
impl<'self, T: Clone, V: Vector<T>> VectorVector<T> for &'self [V] { | ||
/// Flattens a vector of vectors of T into a single vector of T. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation is being moved to the traits for these types of impls, so we might as well do it here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea
Success
|
Avoid unnecessary copying of subvectors, and calculate the needed space beforehand. These implementations are simple but better than the previous. Also only implement it once, for all `Vector<T>` using: impl<'self, T: Clone, V: Vector<T>> VectorVector<T> for &'self [V] performance improved according to the bench test: before test vec::bench::concat ... bench: 74818 ns/iter (+/- 408) test vec::bench::connect ... bench: 87066 ns/iter (+/- 376) after test vec::bench::concat ... bench: 17724 ns/iter (+/- 126) test vec::bench::connect ... bench: 18353 ns/iter (+/- 691) Closes #9581
std::vec::{concat, connect, concat_slices, connect_slices} are replaced by the already existing trait methods .concat_vec() and .connect_vec().
thanks~ |
std::vec: Sane implementations for connect_vec and concat_vec Avoid unnecessary copying of subvectors, and calculate the needed space beforehand. These implementations are simple but better than the previous. Also only implement it once, for all `Vector<T>` using: impl<'self, T: Clone, V: Vector<T>> VectorVector<T> for &'self [V] Closes #9581
std::vec: Sane implementations for connect_vec and concat_vec
Avoid unnecessary copying of subvectors, and calculate the needed space
beforehand. These implementations are simple but better than the
previous.
Also only implement it once, for all
Vector<T>
using:Closes #9581