diff options
author | Jeff King <peff@peff.net> | 2020-02-14 21:22:34 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-02-14 21:46:22 +0300 |
commit | cc4aa28506e079e0c17cfbe78743530795803ea8 (patch) | |
tree | f8881832cb2e89da9722e2330712db21a406fa62 /ewah/bitmap.c | |
parent | 2aaeb9ac414d75f875efa968480db1ce85dc8dc5 (diff) |
bitmap: add bitmap_unset() function
We've never needed to unset an individual bit in a bitmap until now.
Typically they start with all bits unset and we bitmap_set() them, or we
are applying another bitmap as a mask. But the easiest way to apply an
object filter to a bitmap result will be to unset the individual bits.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'ewah/bitmap.c')
-rw-r--r-- | ewah/bitmap.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/ewah/bitmap.c b/ewah/bitmap.c index 52f1178db4..1c31b3e249 100644 --- a/ewah/bitmap.c +++ b/ewah/bitmap.c @@ -45,6 +45,14 @@ void bitmap_set(struct bitmap *self, size_t pos) self->words[block] |= EWAH_MASK(pos); } +void bitmap_unset(struct bitmap *self, size_t pos) +{ + size_t block = EWAH_BLOCK(pos); + + if (block < self->word_alloc) + self->words[block] &= ~EWAH_MASK(pos); +} + int bitmap_get(struct bitmap *self, size_t pos) { size_t block = EWAH_BLOCK(pos); |