From: Paul Brossier Date: Mon, 8 Feb 2010 18:14:12 +0000 (+0100) Subject: src/mathutils.c: simplify aubio_is_power_of_two, thanks to Arturo Castro X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7581185ee07bc7ea58fc9b1667d8245c78a6447c;p=aubio.git src/mathutils.c: simplify aubio_is_power_of_two, thanks to Arturo Castro --- diff --git a/src/mathutils.c b/src/mathutils.c index d443fc1b..2bf3be75 100644 --- a/src/mathutils.c +++ b/src/mathutils.c @@ -441,12 +441,9 @@ aubio_is_power_of_two (uint_t a) uint_t aubio_next_power_of_two (uint_t a) { - uint_t i; - a--; - for (i = 0; i < sizeof (uint_t) * CHAR_BIT; i++) { - a = a | a >> 1; - } - return a + 1; + uint_t i = 1; + while (i < a) i <<= 1; + return i; } smpl_t