Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #31000 - bluss:efficient-clone-from-slice, r=dotdash
Restore indexed formulation of clone_from_slice For good codegen here, we need a lock step iteration where the loop bound is only checked once per iteration; .zip() unfortunately does not optimize this way. If we use a counted loop, and make sure that llvm sees that the bounds check condition is the same as the loop bound condition, the bounds checks are optimized out. For this reason we need to slice `from` (apparently) redundantly. This commit restores the old formulation of clone_from_slice. In this shape, clone_from_slice will again optimize into calling memcpy where possible (for example for &[u8] or &[i32]).
- Loading branch information