Skip to content

Commit

Permalink
fix MSVC Win32 count_digits
Browse files Browse the repository at this point in the history
  • Loading branch information
upsj authored and vitaut committed Jun 4, 2021
1 parent 3eeb084 commit 7c8b35f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -995,12 +995,12 @@ template <> auto count_digits<4>(detail::fallback_uintptr n) -> int;
#ifdef FMT_BUILTIN_CLZ
// Optional version of count_digits for better performance on 32-bit platforms.
FMT_CONSTEXPR20 inline auto count_digits(uint32_t n) -> int {
if (is_constant_evaluated() || FMT_MSC_VER) {
if (is_constant_evaluated()) {
return count_digits_fallback(n);
}
// An optimization by Kendall Willets from https://bit.ly/3uOIQrB.
// This increments the upper 32 bits (log10(T) - 1) when >= T is added.
# define FMT_INC(T) (((sizeof(# T) - 1) << 32) - T)
# define FMT_INC(T) (((sizeof(# T) - 1ull) << 32) - T)
constexpr uint64_t table[] = {
FMT_INC(0), FMT_INC(0), FMT_INC(0), // 8
FMT_INC(10), FMT_INC(10), FMT_INC(10), // 64
Expand Down

0 comments on commit 7c8b35f

Please sign in to comment.