-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exclude fallback functions when FMT_BUILTIN_CLZ(LL) is not defined #2434
Merged
+4
−0
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
901d2a7
exclude fallback functions when FMT_BUILTIN_CLZ(LL) is not defined
ebbbea6
moved ifdefs before function comments
ab273b4
exclude fallback functions when FMT_BUILTIN_CLZ(LL) is not defined
bf23d97
Merge remote-tracking branch 'origin/master'
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
exclude fallback functions when FMT_BUILTIN_CLZ(LL) is not defined
Signed-off-by: Bodo Martin <[email protected]>
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -918,6 +918,7 @@ FMT_CONSTEXPR inline auto count_digits(uint128_t n) -> int { | |
|
||
// It is a separate function rather than a part of count_digits to workaround | ||
// the lack of static constexpr in constexpr functions. | ||
#ifdef FMT_BUILTIN_CLZLL | ||
inline auto do_count_digits(uint64_t n) -> int { | ||
// This has comparable performance to the version by Kendall Willets | ||
// (https://github.com/fmtlib/format-benchmark/blob/master/digits10) | ||
|
@@ -934,6 +935,7 @@ inline auto do_count_digits(uint64_t n) -> int { | |
10000000000000000000ULL}; | ||
return t - (n < zero_or_powers_of_10[t]); | ||
} | ||
#endif | ||
|
||
// Returns the number of decimal digits in n. Leading zeros are not counted | ||
// except for n == 0 in which case count_digits returns 1. | ||
|
@@ -964,6 +966,7 @@ template <> auto count_digits<4>(detail::fallback_uintptr n) -> int; | |
|
||
// It is a separate function rather than a part of count_digits to workaround | ||
// the lack of static constexpr in constexpr functions. | ||
#ifdef FMT_BUILTIN_CLZ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
FMT_INLINE auto do_count_digits(uint32_t n) -> int { | ||
// An optimization by Kendall Willets from https://bit.ly/3uOIQrB. | ||
// This increments the upper 32 bits (log10(T) - 1) when >= T is added. | ||
|
@@ -984,6 +987,7 @@ FMT_INLINE auto do_count_digits(uint32_t n) -> int { | |
auto inc = table[FMT_BUILTIN_CLZ(n | 1) ^ 31]; | ||
return static_cast<int>((n + inc) >> 32); | ||
} | ||
#endif | ||
|
||
// Optional version of count_digits for better performance on 32-bit platforms. | ||
FMT_CONSTEXPR20 inline auto count_digits(uint32_t n) -> int { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move the
#ifdef
right before the comment:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done