[libcxx-commits] [PATCH] D139555: [libc++] Refactor char_traits
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Dec 8 13:27:01 PST 2022
philnik added inline comments.
================
Comment at: libcxx/include/__string/char_traits.h:215
+ if (__n == 0)
+ return 0;
+ return std::__constexpr_memcmp(__s1, __s2, __n);
----------------
Mordante wrote:
> This is odd, I did leave a message here, but it's gone :-/
>
> How about removing this test? I tested in godbolt and Clang and GCC for -O0 and -O2 this generated no code.
> (If wanted I can recreate the example in godbolt.)
Maybe? I've tried and for me it generates code: https://godbolt.org/z/54v99TMo9. Though it's arguably not worth the extra four instructions and branch prediction slot to optimize for comparing nothing. I mainly kept it because I thought it was UB to call `memcmp` with null pointers, but I can't find any evidence of that, so removing I'm it.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139555/new/
https://reviews.llvm.org/D139555
More information about the libcxx-commits
mailing list