projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a749ba3
)
optimize legacy ffs function
author
Rich Felker
<dalias@aerifal.cx>
Thu, 23 Aug 2012 18:38:34 +0000
(14:38 -0400)
committer
Rich Felker
<dalias@aerifal.cx>
Thu, 23 Aug 2012 18:38:34 +0000
(14:38 -0400)
src/misc/ffs.c
patch
|
blob
|
history
diff --git
a/src/misc/ffs.c
b/src/misc/ffs.c
index 2f7cb32198462895a67350e87816849c977c4811..673ce5a9758284c7eca182b32de3902c9b353b3f 100644
(file)
--- 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;
}