You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As the issues rust-lang/rust#106539 and rust-lang/rust#113789 indicate, iter().copied() is more efficient than iter() for small data types because the former one results in less indirections and hence opens up the room for more optimizations. How small is small needs more investigations, but anything <= usize should definitely be small(in fact, the original reply in the issue suggests 8*usize is probably still small enough).
The text was updated successfully, but these errors were encountered:
Dan-wanna-M
changed the title
Document performance difference between iter().copied() and iter() for small data types
Document iter().copied() vs iter() for small data types
Jun 11, 2024
Indeed, there is a comment form a compiler developer that this is extremely difficult for LLVM to optimize, and that putting .copied() early should be encouraged: rust-lang/rust#106539 (comment)
As the issues rust-lang/rust#106539 and rust-lang/rust#113789 indicate, iter().copied() is more efficient than iter() for small data types because the former one results in less indirections and hence opens up the room for more optimizations. How small is small needs more investigations, but anything <=
usize
should definitely be small(in fact, the original reply in the issue suggests8*usize
is probably still small enough).The text was updated successfully, but these errors were encountered: