23 ms·
To answer both my own questions. Rust does not seem to have this same problem: https://godbolt.org/z/JpwcRN https://godbolt.org/z/JpwcRN But iterating over the
by totalperspectiv 7y ago
To answer both my own questions. Rust does not seem to have this same problem:
https://godbolt.org/z/JpwcRN https://godbolt.org/z/JpwcRN
But iterating over the loop with .iter_mut is different than iterating over 0..v.len(), which is interesting.
- masklinn 7y agoI'm guessing its bounds-checking, though replacing v[i] += 1 by `*v.get_unchecked_mut(i) += 1` generates yet another bit of code (it seems to somewhat unroll the loop but stops there). Also you can use `-C target_cpu=native` and get AVX512 instructions on godbolt's.