Browse Source

optimize legacy ffs function

Rich Felker 12 years ago
parent
commit
67ba40d1e0
1 changed files with 2 additions and 4 deletions
  1. 2 4
      src/misc/ffs.c

+ 2 - 4
src/misc/ffs.c

@@ -1,9 +1,7 @@
 #include <strings.h>
+#include "atomic.h"
 
 int ffs(int i)
 {
-	unsigned int j = i;
-	for (i=1; j && !(j&1); j>>=1, i++);
-	if (j) return i;
-	return 0;
+	return i ? a_ctz_l(i)+1 : 0;
 }