From a20dba65bbdf62441024443a608f83f508729ea4 Mon Sep 17 00:00:00 2001 From: Roman Koshelev Date: Tue, 31 Aug 2021 07:51:06 +0300 Subject: [PATCH] Fix copy_str performance --- include/fmt/core.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 2f0cfb0b72c5..1fda229e274a 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -325,6 +325,8 @@ template using bool_constant = std::integral_constant; template using remove_reference_t = typename std::remove_reference::type; template +using remove_const_t = typename std::remove_const::type; +template using remove_cvref_t = typename std::remove_cv>::type; template struct type_identity { using type = T; }; template using type_identity_t = typename type_identity::type; @@ -746,13 +748,14 @@ FMT_CONSTEXPR auto copy_str(InputIt begin, InputIt end, OutputIt out) return out; } -template ::value)> -FMT_CONSTEXPR auto copy_str(const Char* begin, const Char* end, Char* out) - -> Char* { +template , U>::value && is_char::value)> +FMT_CONSTEXPR auto copy_str(T* begin, T* end, U* out) + -> U* { if (is_constant_evaluated()) - return copy_str(begin, end, out); + return copy_str(begin, end, out); auto size = to_unsigned(end - begin); - memcpy(out, begin, size); + memcpy(out, begin, size * sizeof(U)); return out + size; }