[libc++] Consider optimizing std::copy & friends for small input ranges known at compile-time
Open
libc++
performance
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Right now, we always fall back to memcpy for trivially copyable types, no matter how large the sequence. This means that copying even a small range (e.g. 2 elements) requires making a call to `memcpy`, which may be more expensive than doing the copy itself. If we could detect at compile-time that we have only a small number of elements, we could do the copy manually instead of calling `memcpy`. Something like the idea in https://godbolt.org/z/14je1zMcn, but implemented in a way that's actually better than the status quo.
Contributor guide
Assessment
This issue has not been assessed yet.