Am 10.07.2017 um 09:27 schrieb Jeff King:
On Sat, Jul 08, 2017 at 12:35:35PM +0200, René Scharfe wrote:
diff --git a/ewah/ewah_bitmap.c b/ewah/ewah_bitmap.c
index 2dc9c82ecf..06c479f70a 100644
--- a/ewah/ewah_bitmap.c
+++ b/ewah/ewah_bitmap.c
@@ -210,8 +210,8 @@ size_t ewah_add(struct ewah_bitmap *self, eword_t word)
void ewah_set(struct ewah_bitmap *self, size_t i)
{
const size_t dist =
- (i + BITS_IN_EWORD) / BITS_IN_EWORD -
- (self->bit_size + BITS_IN_EWORD - 1) / BITS_IN_EWORD;
+ DIV_ROUND_UP(i + 1, BITS_IN_EWORD) -
+ DIV_ROUND_UP(self->bit_size, BITS_IN_EWORD);
...this first one is a bit trickier. Our "n" in the first one is now
"i+1". But that's because the original was implicitly canceling the
"-1" and "+1" terms.
So I think it's a true mechanical conversion, but I have to admit the
original is confusing. Without digging I suspect it's correct, though,
just because a simple bug here would mean that our ewah bitmaps totally
don't work. So it's probably not worth spending time on.
A few lines below there is "self->bit_size = i + 1", so the code
calculates how many words the old and the new value are apart (or by how
many words the bitmap needs to be extended), which becomes easier to see
with the patch.
René