1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

MathsFunctions: Make countNumberOfBits constexpr

This commit is contained in:
reuk 2022-09-11 19:02:33 +01:00
parent b70b7a309d
commit 21d87c02c2
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -548,7 +548,7 @@ inline int nextPowerOfTwo (int n) noexcept
int findHighestSetBit (uint32 n) noexcept;
/** Returns the number of bits in a 32-bit integer. */
inline int countNumberOfBits (uint32 n) noexcept
constexpr int countNumberOfBits (uint32 n) noexcept
{
n -= ((n >> 1) & 0x55555555);
n = (((n >> 2) & 0x33333333) + (n & 0x33333333));
@ -559,7 +559,7 @@ inline int countNumberOfBits (uint32 n) noexcept
}
/** Returns the number of bits in a 64-bit integer. */
inline int countNumberOfBits (uint64 n) noexcept
constexpr int countNumberOfBits (uint64 n) noexcept
{
return countNumberOfBits ((uint32) n) + countNumberOfBits ((uint32) (n >> 32));
}