llvm / llvm/llvm-project

[libc++] Consider optimizing std::copy & friends for small input ranges known at compile-time

Open
#224,037 1 comment 1 reaction 1 assignee Claimed by @philnik777 View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.