3 ms·
> Is this abstraction zero-cost? What's the overhead? It will cost a single correctly predicted branch, which is effectively free on modern architectures. Any
by civility 10y ago
> Is this abstraction zero-cost? What's the overhead?
It will cost a single correctly predicted branch, which is effectively free on modern architectures. Any "safe" language will have to make this conditional branch too (Rust's File::read method will check the size of the slice).
- Ericson2314 10y agoNope. Iterators in Rust can be used to safely avoid bounds checking in ways that would be impossible to enforce in C.
- civility 10y agoWe were talking about reading into a bounds checked array. Rust does not user iterators for this.
- Ericson2314 10y agoI cannot trust people to correctly iterate in order through an array in C, and thus must resort to bounds checking them.
- civility 10y agoThis still has nothing to do with what I've said. Take care.