umanwizard:
for i in 0..n
If you're going to loop over indices like that, then you should always use reslicing to make it clear up-front to LLVM that things are in-bounds. For more info, read
Don't use &Vec<T> parameters; use &[T] instead. It's just a pure win -- less indirection, more flexible for your callers, and doesn't actually keep you from doing anything.
Use "reslicing" to make it as obvious as possible to LLVM that your array indexes are in-bounds, if you're going to use indexes into multiple slices.
For example, this emits two bounds checks every iteration, because it needs to write the correct prefix of z and panic in the correct place if x or y is actually short…
5 Likes