draw: re-implement free_bit() with ffs()
authorBrian Paul <brianp@vmware.com>
Wed, 3 Feb 2010 04:17:56 +0000 (21:17 -0700)
committerBrian Paul <brianp@vmware.com>
Wed, 3 Feb 2010 04:17:56 +0000 (21:17 -0700)
src/gallium/auxiliary/draw/draw_pipe_aaline.c
src/gallium/auxiliary/draw/draw_pipe_pstipple.c

index 4585dcdb48ab8f39dc911d868e0d4fb5a67db27f..54bb9d4b84a35e2bb19bb8aba9c9fc8702aec961 100644 (file)
@@ -178,12 +178,7 @@ aa_transform_decl(struct tgsi_transform_context *ctx,
 static int
 free_bit(uint bitfield)
 {
-   int i;
-   for (i = 0; i < 32; i++) {
-      if ((bitfield & (1 << i)) == 0)
-         return i;
-   }
-   return -1;
+   return ffs(~bitfield) - 1;
 }
 
 
index 0cc2b7186416dce314a29d1a3f984360612b0298..5f5db7e984b25c8e32b95a309f724bcaaf347c29 100644 (file)
@@ -171,12 +171,7 @@ pstip_transform_immed(struct tgsi_transform_context *ctx,
 static int
 free_bit(uint bitfield)
 {
-   int i;
-   for (i = 0; i < 32; i++) {
-      if ((bitfield & (1 << i)) == 0)
-         return i;
-   }
-   return -1;
+   return ffs(~bitfield) - 1;
 }