4 ms·
I'm sure Rust also has a way to disable bounds/overflow checks for speed. Do benchmarks utilise it?
by dom96 5y ago
I'm sure Rust also has a way to disable bounds/overflow checks for speed. Do benchmarks utilise it?
- formerly_proven 5y agoRust should be able to elide more checks than most other languages without impacting safety.
- dom96 5y agoThat's the assumption, but that doesn't mean it's the case. Certainly bounds checks are impossible to prove at compile-time.
- ObscureScience 5y agoWhat language are you talking about?
- nicoburns 5y agoRust doesn’t have a compiler flag for this, instead it has separate functions that don’t do the checking. E.g. Vec has a .get_unchecked function. Such functions can only be used in an unsafe block, and should only be used if bounds checking is handled elsewhere such that it would be impossible to cause an out of bounds error at runtime. It’s also often possible to get rust to elide bounds checks by using iterators, which often don’t need them as they know the length up front.