1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Optimize is_power_of_two.

This commit is contained in:
Philippe Michaud-Boudreault 2016-11-06 17:34:36 +01:00 committed by Jonas 'Sortie' Termansen
parent 5585303365
commit 4890297611

View file

@ -44,10 +44,7 @@ namespace ELF {
static bool is_power_of_two(uintptr_t value)
{
for ( uintptr_t i = 0; i < sizeof(uintptr_t) * 8; i++ )
if ( (uintptr_t) 1 << i == value )
return true;
return false;
return value && !(value & (value - 1));
}
uintptr_t Load(const void* file_ptr, size_t file_size, Auxiliary* aux)