From a58c1338216d2b712f0bd231ec4229db88a06f90 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 7 Sep 2021 19:34:13 -0700 Subject: [PATCH] Improve code_point_length codegen on older gcc --- include/fmt/core.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 1f782647..cba989c3 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -94,7 +94,7 @@ # define FMT_CONSTEXPR_DECL #endif -#if ((__cplusplus >= 202002L) && \ +#if ((__cplusplus >= 202002L) && \ (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE > 9)) || \ (__cplusplus >= 201709L && FMT_GCC_VERSION >= 1002) # define FMT_CONSTEXPR20 constexpr @@ -2140,8 +2140,8 @@ constexpr auto to_ascii(Char value) -> template FMT_CONSTEXPR auto code_point_length(const Char* begin) -> int { if (const_check(sizeof(Char) != 1)) return 1; - constexpr char lengths[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 4, 0}; + auto lengths = + "\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\0\0\0\0\0\0\0\0\2\2\2\2\3\3\4"; int len = lengths[static_cast(*begin) >> 3]; // Compute the pointer to the next character early so that the next