From 2156d33b49b8e5e782573695eca47b2c04d0ab9d Mon Sep 17 00:00:00 2001 From: Guillaume Chatelet Date: Tue, 17 Jan 2023 11:05:50 +0000 Subject: [PATCH] [libc] Fix memcpy inefficiency --- libc/src/string/memory_utils/memcpy_implementations.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libc/src/string/memory_utils/memcpy_implementations.h b/libc/src/string/memory_utils/memcpy_implementations.h index 4372733..8ae237f 100644 --- a/libc/src/string/memory_utils/memcpy_implementations.h +++ b/libc/src/string/memory_utils/memcpy_implementations.h @@ -75,15 +75,15 @@ inline_memcpy_x86_maybe_interpose_repmovsb(Ptr __restrict dst, static constexpr size_t kRepMovsbThreshold = LLVM_LIBC_MEMCPY_X86_USE_REPMOVSB_FROM_SIZE; - if constexpr (kRepMovsbThreshold == 0) + if constexpr (kRepMovsbThreshold == 0) { return x86::Memcpy::repmovsb(dst, src, count); - else if constexpr (kRepMovsbThreshold > 0) { + } else if constexpr (kRepMovsbThreshold == size_t(-1)) { + return inline_memcpy_x86(dst, src, count); + } else { if (unlikely(count >= kRepMovsbThreshold)) return x86::Memcpy::repmovsb(dst, src, count); else return inline_memcpy_x86(dst, src, count); - } else { - return inline_memcpy_x86(dst, src, count); } } #endif // defined(LLVM_LIBC_ARCH_X86) -- 2.7.4