On 1/22/13 10:37 AM, Sami Nopanen wrote:
Anyway, this brings me to yet another question/concern regarding mutable managed vectors: I was reading pcwaltons blog regarding the new borrow checker rules. It mentions that for managed mutable boxes, attempting to mutate will go through runtime checks to enforce these rules. It wasn't quite clear on when these runtime checks actually do occur. Let's say I'm representing a large matrix as @mut [float], and make a function to do some operating on it:fn fooOp(data : &mut [float]) { for uint::range(0u, vec::len(data)) |idx| { data[idx] = someOp(data[idx]); } } Will the new borrow checker now cause such tight inner loops (that would be a pretty common use case I'd assume) to have additional runtime overhead?
There's no runtime overhead for the code you wrote. The check is performed at the moment you borrow the `@mut [float]` vector to `&mut [float]`, and no checks are performed as long as the `&mut [float]` pointer remains alive.
Patrick _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
