Skip to content

Commit 2945eef

Browse files
Gowntafacebook-github-bot
authored andcommitted
Use constexpr
Summary: This code has a warning-suppression hack that constexpr can fix. Was originally added as a pull request in 2021 in D28692386. Reviewed By: skrueger Differential Revision: D76546781 fbshipit-source-id: e3782a0261b99501840645539d87b1db57d2740d
1 parent c1aae38 commit 2945eef

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

third-party/folly/src/folly/lang/ToAscii.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,8 @@ FOLLY_ALWAYS_INLINE size_t to_ascii_size_clzll(uint64_t v) {
209209
// log2 is approx log<2>(v)
210210
size_t const vlog2 = 64 - static_cast<size_t>(__builtin_clzll(v));
211211

212-
// work around msvc warning C4127 (conditional expression is constant)
213-
bool false_ = false;
214-
215212
// handle directly when Base is power-of-two
216-
if (false_ || !(Base & (Base - 1))) {
213+
if constexpr (!(Base & (Base - 1))) {
217214
constexpr auto const blog2 = constexpr_log2(Base);
218215
return vlog2 / blog2 + size_t(vlog2 % blog2 != 0);
219216
}

0 commit comments

Comments
 (0)