How to avoid bounds checks in Rust (without unsafe!)
You can often hear online that indexing into a slice, such as my_slice[i] is slow in Rust and you should do something else instead for performance. The details, however, are murky. There’s little in the way of benchmarks, and hardly any documentation on removing this overhead without resorting to unsafe code. So after optimizing a bunch of high-profile crates by removing bounds checks (and also removing unsafe code from some of them), I figured I should write down the results, and the techniques I discovere
评论
?
参与讨论