From 2a2f73f7c197e41820757cea84d33d6875cc2f54 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Thu, 29 Aug 2024 19:12:55 -0700 Subject: [PATCH] Improve binary size --- include/fmt/base.h | 8 ++++++-- include/fmt/format.h | 6 +----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/fmt/base.h b/include/fmt/base.h index 3e302f92..ee3c79f3 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -227,7 +227,7 @@ # define FMT_NO_UNIQUE_ADDRESS #endif -#ifdef FMT_INLINE +#ifdef FMT_ALWAYS_INLINE // Use the provided definition. #elif FMT_GCC_VERSION || FMT_CLANG_VERSION # define FMT_ALWAYS_INLINE inline __attribute__((always_inline)) @@ -1657,6 +1657,10 @@ struct is_output_iterator< void_t&>()++ = std::declval())>> : std::true_type {}; +#ifndef FMT_OPTIMIZE_SIZE +# define FMT_OPTIMIZE_SIZE 0 +#endif + #ifdef FMT_USE_LOCALE // Use the provided definition. #elif defined(FMT_STATIC_THOUSANDS_SEPARATOR) @@ -2779,7 +2783,7 @@ FMT_CONSTEXPR void parse_format_string(basic_string_view format_str, Handler&& handler) { auto begin = format_str.data(); auto end = begin + format_str.size(); - if (end - begin < 32) { + if (FMT_OPTIMIZE_SIZE || end - begin < 32) { // Use a simple loop instead of memchr for small strings. const Char* p = begin; while (p != end) { diff --git a/include/fmt/format.h b/include/fmt/format.h index f7b2ab86..93fa6600 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1166,10 +1166,6 @@ FMT_CONSTEXPR inline auto count_digits(uint128_opt n) -> int { } #endif -#ifndef FMT_OPTIMIZE_SIZE -# define FMT_OPTIMIZE_SIZE 0 -#endif - #ifdef FMT_BUILTIN_CLZLL // It is a separate function rather than a part of count_digits to workaround // the lack of static constexpr in constexpr functions. @@ -3677,7 +3673,7 @@ template struct default_arg_formatter { template struct arg_formatter { basic_appender out; const format_specs& specs; - locale_ref locale; + FMT_NO_UNIQUE_ADDRESS locale_ref locale; template ::value)> FMT_CONSTEXPR FMT_INLINE void operator()(T value) {