[libcxx-commits] [libcxx] [libc++] Treat negative counts in copy_n & friends as no-ops (PR #207086)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jul 2 09:27:32 PDT 2026
================
@@ -63,14 +63,15 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
copy_n(_InputIterator __first, _Size __n, _OutputIterator __result) {
using _IntegralSize = decltype(std::__convert_to_integral(__n));
_IntegralSize __converted = __n;
- if (__converted > 0) {
+ if (__converted < 0) [[__unlikely__]]
----------------
philnik777 wrote:
Unless there is a clear benefit I'd remove it. This is the sort of check I'd expect to be removed in most cases anyways, and it looks to me like it's just as likely to hinder optimizations as it helps in the few cases it won't be removed.
https://github.com/llvm/llvm-project/pull/207086
More information about the libcxx-commits
mailing list