Browse Source
The previous implementation shifted a signed 32-bit value by up to 31 bits, which is implementation-defined behavior. It also had a fixed 32-bit limit and different semantics from the compiler built-ins. Use unsigned integer semantics and Brian Kernighan's method for the portable popcount implementation. This avoids implementation-defined signed right shifts and counts all bits in the unsigned integer type, matching the semantics of the compiler built-ins and C++20 std::popcount, and should have a minor speed improvement for random samples. Found by cppcheck (shiftTooManyBitsSigned) Signed-off-by: Robin Getz <rgetz503@gmail.com>chirpmodem-v8.0.0
1 changed files with 10 additions and 4 deletions
Loading…
Reference in new issue