4 ms·
They have bound checking through the `vec.at(index)` method, not through the indexing operator `vec[index]`. Most people won't even look at the `at` method, the
by SkiFire13 3y ago
They have bound checking through the `vec.at(index)` method, not through the indexing operator `vec[index]`. Most people won't even look at the `at` method, they will just use the indexing operator since that's supposed to be the "default" .
- pjmlp 3y agoWhile true, most compilers do enable bounds checking in debug releases, and there are compiler flags to keep those checks enabled in release builds.
- tialaramex 3y agoThis is differently bad because it may mean tight loops are enormously slower under debug for no good reason, it's an adverse consequence of the C++ "wrong defaults" problem. Because they're defaults, we can't detect whether they're what was specifically needed or just nobody cared, so we guess nobody cared and act accordingly.
- pjmlp 3y agoIt isn't as if Rust is any different in this regard.
- tialaramex 3y agoI'd argue exactly the contrary. In Rust you went out of your way to write the unsafe thing because that's specifically what you intended. As a result there's no need to try to guess whether this code doesn't care, if it didn't care it would be checked because that's the default.