Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/draco/core/bit_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,19 @@ inline int MostSignificantBit(uint32_t n) {
#if defined(__GNUC__)
return 31 ^ __builtin_clz(n);
#elif defined(_MSC_VER)

unsigned long where;
_BitScanReverse(&where, n);
return (int)where;
#else
// TODO(fgalligan): Optimize this code.
int msb = -1;
while (n != 0) {
msb++;
n >>= 1;
uint32_t msb = 0;
if (n) {
if (0xFFFF0000 & n) { n >>= (1 << 4); msb |= (1 << 4); }
if (0x0000FF00 & n) { n >>= (1 << 3); msb |= (1 << 3); }
if (0x000000F0 & n) { n >>= (1 << 2); msb |= (1 << 2); }
if (0x0000000C & n) { n >>= (1 << 1); msb |= (1 << 1); }
if (0x00000002 & n) { msb |= (1 << 0); }
} else {
msb = -1;
}
return msb;
#endif
Expand Down
Loading