|
|
|
|
|
by ridiculous_fish
553 days ago
|
|
SIMD is true, but the original guess is correct, and that effect is bigger! using_map is faster because it's not allocating: it's re-using the input array. That is, it is operating on the input `v` value in place, equivalent to this: pub fn using_map(mut v: Vec<i32>) -> Vec<i32> {
v.iter_mut().for_each(|c| *c += 1);
v
}
This is a particularly fancy optimization that Rust can perform. |
|
[1] https://godbolt.org/z/K9z6PvdYh