Skip to content

Commit

Permalink
hbitmap: Use non-bitops ctzl
Browse files Browse the repository at this point in the history
Both uses of ctz have already eliminated zero, and thus the difference
in edge conditions between the two routines is irrelevant.

Signed-off-by: Richard Henderson <[email protected]>
Acked-by: Paolo Bonzini <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Blue Swirl <[email protected]>
  • Loading branch information
rth7680 authored and blueswirl committed Feb 16, 2013
1 parent 72d8115 commit 18331e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion include/qemu/hbitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "bitops.h"
#include "host-utils.h"

typedef struct HBitmap HBitmap;
typedef struct HBitmapIter HBitmapIter;
Expand Down Expand Up @@ -170,7 +171,7 @@ static inline int64_t hbitmap_iter_next(HBitmapIter *hbi)

/* The next call will resume work from the next bit. */
hbi->cur[HBITMAP_LEVELS - 1] = cur & (cur - 1);
item = ((uint64_t)hbi->pos << BITS_PER_LEVEL) + bitops_ctzl(cur);
item = ((uint64_t)hbi->pos << BITS_PER_LEVEL) + ctzl(cur);

return item << hbi->granularity;
}
Expand Down
3 changes: 2 additions & 1 deletion util/hbitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ unsigned long hbitmap_iter_skip_words(HBitmapIter *hbi)
* The index of this word's least significant set bit provides
* the low-order bits.
*/
pos = (pos << BITS_PER_LEVEL) + bitops_ctzl(cur);
assert(cur);
pos = (pos << BITS_PER_LEVEL) + ctzl(cur);
hbi->cur[i] = cur & (cur - 1);

/* Set up next level for iteration. */
Expand Down

0 comments on commit 18331e7

Please sign in to comment.