From 7581185ee07bc7ea58fc9b1667d8245c78a6447c Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 8 Feb 2010 19:14:12 +0100 Subject: [PATCH] src/mathutils.c: simplify aubio_is_power_of_two, thanks to Arturo Castro --- src/mathutils.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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 -- 2.26.2