8 ms·
I'm struggling to understand how requiring explicit mutability has anything to do with performance or "hoops." I mean, getting mutable access is trivial: le
by sidlls 10y ago
I'm struggling to understand how requiring explicit mutability has anything to do with performance or "hoops."
I mean, getting mutable access is trivial:
let mut x = ...
fn frobnicate(x: &mut...)
The performance "problems" in Rust requiring "hoops" are in very narrow applications (e.g. certain applications of high performance numerical computing). I'm not a fan of the "unsafe-offset" idiom required so that every time access into a vector occurs doesn't waste cycles on a pointless boundary check (for example).
But I must say for a given chunk of Rust code the equivalent C++ code is generally more bloated, because unless you're writing code begging for abuse you're going to have "const" and move operations everywhere, which is sort of inverted from Rust's model.
- steveklabnik 10y agoBounds checks are often elided, so many access of vectors won't waste cycles on pointless checks. Or at least, if they are truly pointless, and they're not elided, that's an LLVM bug.