Skip to content

Commit

Permalink
Improve binary size
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Aug 30, 2024
1 parent 6dd9194 commit 2a2f73f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 6 additions & 2 deletions include/fmt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -1657,6 +1657,10 @@ struct is_output_iterator<
void_t<decltype(*std::declval<decay_t<It>&>()++ = std::declval<T>())>>
: 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)
Expand Down Expand Up @@ -2779,7 +2783,7 @@ FMT_CONSTEXPR void parse_format_string(basic_string_view<Char> 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) {
Expand Down
6 changes: 1 addition & 5 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -3677,7 +3673,7 @@ template <typename Char> struct default_arg_formatter {
template <typename Char> struct arg_formatter {
basic_appender<Char> out;
const format_specs& specs;
locale_ref locale;
FMT_NO_UNIQUE_ADDRESS locale_ref locale;

template <typename T, FMT_ENABLE_IF(is_builtin<T>::value)>
FMT_CONSTEXPR FMT_INLINE void operator()(T value) {
Expand Down

0 comments on commit 2a2f73f

Please sign in to comment.