From f00a6550fa364c42927f2cb7dd01253a3048e99e Mon Sep 17 00:00:00 2001 From: gabime Date: Fri, 17 Jan 2025 19:13:36 +0200 Subject: [PATCH] Fixed some tidy warnings --- include/spdlog/details/fmt_helper.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/include/spdlog/details/fmt_helper.h b/include/spdlog/details/fmt_helper.h index 62581891..6a519d47 100644 --- a/include/spdlog/details/fmt_helper.h +++ b/include/spdlog/details/fmt_helper.h @@ -14,12 +14,12 @@ namespace details { namespace fmt_helper { inline void append_string_view(spdlog::string_view_t view, memory_buf_t &dest) { - auto *buf_ptr = view.data(); + const auto *buf_ptr = view.data(); dest.append(buf_ptr, buf_ptr + view.size()); } template -inline void append_int(T n, memory_buf_t &dest) { +void append_int(T n, memory_buf_t &dest) { fmt::format_int i(n); dest.append(i.data(), i.data() + i.size()); } @@ -36,14 +36,14 @@ constexpr unsigned int count_digits_fallback(T n) { if (n < 100) return count + 1; if (n < 1000) return count + 2; if (n < 10000) return count + 3; - n /= 10000u; + n /= 10000U; count += 4; } } template inline unsigned int count_digits(T n) { - using count_type = typename std::conditional<(sizeof(T) > sizeof(uint32_t)), uint64_t, uint32_t>::type; + using count_type = std::conditional_t<(sizeof(T) > sizeof(uint32_t)), uint64_t, uint32_t>; return static_cast(fmt:: // fmt 7.0.0 renamed the internal namespace to detail. @@ -59,8 +59,8 @@ inline unsigned int count_digits(T n) { inline void pad2(int n, memory_buf_t &dest) { if (n >= 0 && n < 100) // 0-99 { - dest.push_back(static_cast('0' + n / 10)); - dest.push_back(static_cast('0' + n % 10)); + dest.push_back(static_cast('0' + (n / 10))); + dest.push_back(static_cast('0' + (n % 10))); } else // unlikely, but just in case, let fmt deal with it { fmt_lib::format_to(std::back_inserter(dest), SPDLOG_FMT_STRING("{:02}"), n); @@ -69,18 +69,18 @@ inline void pad2(int n, memory_buf_t &dest) { template inline void pad_uint(T n, unsigned int width, memory_buf_t &dest) { - static_assert(std::is_unsigned::value, "pad_uint must get unsigned T"); - for (auto digits = count_digits(n); digits < width; digits++) { + static_assert(std::is_unsigned_v, "pad_uint must get unsigned T"); + for (auto digits = count_digits(n); digits < width; ++digits) { dest.push_back('0'); } append_int(n, dest); } template -inline void pad3(T n, memory_buf_t &dest) { - static_assert(std::is_unsigned::value, "pad3 must get unsigned T"); +void pad3(T n, memory_buf_t &dest) { + static_assert(std::is_unsigned_v, "pad3 must get unsigned T"); if (n < 1000) { - dest.push_back(static_cast(n / 100 + '0')); + dest.push_back(static_cast((n / 100) + '0')); n = n % 100; dest.push_back(static_cast((n / 10) + '0')); dest.push_back(static_cast((n % 10) + '0')); @@ -90,12 +90,12 @@ inline void pad3(T n, memory_buf_t &dest) { } template -inline void pad6(T n, memory_buf_t &dest) { +void pad6(T n, memory_buf_t &dest) { pad_uint(n, 6, dest); } template -inline void pad9(T n, memory_buf_t &dest) { +void pad9(T n, memory_buf_t &dest) { pad_uint(n, 9, dest); } @@ -103,7 +103,7 @@ inline void pad9(T n, memory_buf_t &dest) { // e.g. // fraction(tp) -> will return the millis part of the second template -inline ToDuration time_fraction(log_clock::time_point tp) { +ToDuration time_fraction(log_clock::time_point tp) { using std::chrono::duration_cast; using std::chrono::seconds; auto duration = tp.time_since_epoch();