[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] virsh: use faster bit search



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 |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index ef8dea3..0dcc66b 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -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"

 static char *progname;

@@ -12280,7 +12280,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);
-- 
1.7.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]