3 ms·
> Surprisingly, rustc optimizer makes sure that this performs as well as the index-wrangling implementation (according to some simple tests I just ran). Freque
by bbatha 11y ago
> Surprisingly, rustc optimizer makes sure that this performs as well as the index-wrangling implementation (according to some simple tests I just ran).
Frequently functional style optimizes better than the equivalent loop and index implementations because the iterator functional implementation cannot go out of bounds on the array, so the bounds checks that are implicit in indexing are elided.