]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virsh: use faster bit search
authorEric Blake <eblake@redhat.com>
Fri, 15 Jul 2011 21:49:37 +0000 (15:49 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 25 Jul 2011 21:57:51 +0000 (15:57 -0600)
Now that gnulib gives us ffs, we might as well use it.

* tools/virsh.c (vshCmddefGetData): Use ffs rather than
count_one_bits.

tools/virsh.c

index ad0a2c3f974e02dcbf38422f90b994737fe22823..f2fd9e550dcea3cbd034d48b9acc9d2298b9c1bd 100644 (file)
@@ -32,6 +32,7 @@
 #include <inttypes.h>
 #include <signal.h>
 #include <poll.h>
+#include <strings.h>
 
 #include <libxml/parser.h>
 #include <libxml/tree.h>
@@ -57,7 +58,6 @@
 #include "configmake.h"
 #include "threads.h"
 #include "command.h"
-#include "count-one-bits.h"
 #include "virkeycode.h"
 
 static char *progname;
@@ -12852,7 +12852,7 @@ vshCmddefGetData(const vshCmdDef *cmd, uint32_t *opts_need_arg,
         return NULL;
 
     /* Grab least-significant set bit */
-    i = count_one_bits(*opts_need_arg ^ (*opts_need_arg - 1)) - 1;
+    i = ffs(*opts_need_arg) - 1;
     opt = &cmd->opts[i];
     if (opt->type != VSH_OT_ARGV)
         *opts_need_arg &= ~(1 << i);