Closed
Description
pub unsafe fn copy(slice: &[u8], dst: *mut u8) {
let mut src = slice.as_ptr();
let mut dst = dst;
for _ in 0..slice.len() {
*dst = *src;
src = src.add(1);
dst = dst.add(1);
}
}
This doesn't currently compile to a memcpy
(Godbolt).
I figured this was worth filing because this seems to be the main reason that a naive iter::Zip
implementation isn't optimal, which is why it's implemented the way it is.
Metadata
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Category: An issue proposing an enhancement or a PR with one.Issue: Problems and improvements with respect to performance of generated code.Relevant to the compiler team, which will review and decide on the PR/issue.