diff options
| author | Rich Felker <dalias@aerifal.cx> | 2012-08-23 14:38:34 -0400 | 
|---|---|---|
| committer | Rich Felker <dalias@aerifal.cx> | 2012-08-23 14:38:34 -0400 | 
| commit | 67ba40d1e05c39ffe71294476d2f2c13c481f3bd (patch) | |
| tree | 918504a848a72abdfa4a24df8d8f8c1a7b9d95af | |
| parent | a749ba3adc2f3b4abfc68b21d4c3741b20c8f657 (diff) | |
| download | musl-67ba40d1e05c39ffe71294476d2f2c13c481f3bd.tar.gz | |
optimize legacy ffs function
| -rw-r--r-- | src/misc/ffs.c | 6 | 
1 files changed, 2 insertions, 4 deletions
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 <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;  }  | 
