use mi_is_power_of_two when possible (pr #118)

This commit is contained in:
daan 2019-09-09 08:12:50 -07:00
parent b104e434e4
commit ce81af1119
2 changed files with 5 additions and 3 deletions

View file

@ -167,10 +167,12 @@ static inline bool mi_mul_overflow(size_t count, size_t size, size_t* total) {
#endif
}
// Align upwards
static inline uintptr_t _mi_is_power_of_two(uintptr_t x) {
// Is `x` a power of two?
static inline bool _mi_is_power_of_two(uintptr_t x) {
return ((x & (x - 1)) == 0);
}
// Align upwards
static inline uintptr_t _mi_align_up(uintptr_t sz, size_t alignment) {
uintptr_t mask = alignment - 1;
if ((alignment & mask) == 0) { // power of two?