From: Rich Felker Date: Thu, 23 Aug 2012 18:38:34 +0000 (-0400) Subject: optimize legacy ffs function X-Git-Tag: v0.9.5~81 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=67ba40d1e05c39ffe71294476d2f2c13c481f3bd;p=oweals%2Fmusl.git optimize legacy ffs function --- diff --git a/src/misc/ffs.c b/src/misc/ffs.c index 2f7cb321..673ce5a9 100644 --- a/src/misc/ffs.c +++ b/src/misc/ffs.c @@ -1,9 +1,7 @@ #include +#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; }