-
Notifications
You must be signed in to change notification settings - Fork 13k
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
add append to vec with tests and benchmarks #21330
add append to vec with tests and benchmarks #21330
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see CONTRIBUTING.md for more information. |
/// let mut vec2 = vec![4i, 5, 6]; | ||
/// vec.append(&mut vec2); | ||
/// assert_eq!(vec, vec![1i, 2, 3, 4, 5, 6]); | ||
/// assert_eq!(vec2, Vec::new::<i>()); |
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.
Does vec![]
not infer correctly here?
Generally we only add benchmarks when we're trying to establish that a change has a desired performance impact. Adding them for every feature is kinda unwieldy (just slows everything else down). |
Actual code seems legit, just style nits. 👍 |
I've addressed the previous comments. |
Oh derp. Yeah no worries. |
@@ -2777,4 +2823,54 @@ mod tests { | |||
fn bench_clone_from_10_1000_0100(b: &mut Bencher) { | |||
do_bench_clone_from(b, 10, 1000, 100) | |||
} | |||
|
|||
fn do_bench_append(b: &mut Bencher, dst_len: uint, src_len: uint) { |
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.
I would still drop these benches.
r=me with benches removed, and commits squashed. |
74e4f3e
to
08e712e
Compare
r=Gankro |
…-add-append-and-split-off, r=Gankro Please review carefully. Contains unsafe and is my first commit to Rust. Uses ptr::copy_nonoverlapping_memory. Attempts to handle zero-size types correctly.
Congrats! Hope to see more from you in the future. 😄 |
I am a bit unhappy about the naming, as it's moving the elements out of the argument. I wouldn't expect that. But I don't have a better name for it... |
This name was accepted in an RFC: rust-lang/rfcs#509 |
ok. would have been cleaner to have sth. like |
Why does |
@andrewrk: Hm, after thinking about it, yes |
Ok, we have |
basically nothing in Rust actually uses the term |
And push_all is a non-normative performance hack |
(There's |
@gankro: In the past there was |
Please review carefully. Contains unsafe and is my first commit to Rust.
Uses ptr::copy_nonoverlapping_memory. Attempts to handle zero-size types correctly.