shithub: aubio

Download patch

ref: 7581185ee07bc7ea58fc9b1667d8245c78a6447c
parent: d453a4a212948f495c7a070975d247d5a6ae3f8a
author: Paul Brossier <piem@piem.org>
date: Mon Feb 8 14:14:12 EST 2010

src/mathutils.c: simplify aubio_is_power_of_two, thanks to Arturo Castro

--- a/src/mathutils.c
+++ b/src/mathutils.c
@@ -441,12 +441,9 @@
 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