mirror of https://github.com/xqemu/xqemu.git
hbitmap: Use non-bitops ctzl
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 <rth@twiddle.net> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
72d81155d0
commit
18331e7c18
|
@ -16,6 +16,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "bitops.h"
|
#include "bitops.h"
|
||||||
|
#include "host-utils.h"
|
||||||
|
|
||||||
typedef struct HBitmap HBitmap;
|
typedef struct HBitmap HBitmap;
|
||||||
typedef struct HBitmapIter HBitmapIter;
|
typedef struct HBitmapIter HBitmapIter;
|
||||||
|
@ -170,7 +171,7 @@ static inline int64_t hbitmap_iter_next(HBitmapIter *hbi)
|
||||||
|
|
||||||
/* The next call will resume work from the next bit. */
|
/* The next call will resume work from the next bit. */
|
||||||
hbi->cur[HBITMAP_LEVELS - 1] = cur & (cur - 1);
|
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;
|
return item << hbi->granularity;
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,8 @@ unsigned long hbitmap_iter_skip_words(HBitmapIter *hbi)
|
||||||
* The index of this word's least significant set bit provides
|
* The index of this word's least significant set bit provides
|
||||||
* the low-order bits.
|
* 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);
|
hbi->cur[i] = cur & (cur - 1);
|
||||||
|
|
||||||
/* Set up next level for iteration. */
|
/* Set up next level for iteration. */
|
||||||
|
|
Loading…
Reference in New Issue