git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Jeff King <peff@peff.net>
Cc: Git List <git@vger.kernel.org>, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] use DIV_ROUND_UP
Date: Mon, 10 Jul 2017 19:08:38 +0200	[thread overview]
Message-ID: <3f643932-0fe1-26b0-d2bf-a2124a74deca@web.de> (raw)
In-Reply-To: <20170710072701.cqzztww6mrqr7sli@sigill.intra.peff.net>

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é

  reply	other threads:[~2017-07-10 17:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-08 10:35 [PATCH] use DIV_ROUND_UP René Scharfe
2017-07-09 13:25 ` Martin Ågren
2017-07-09 14:01   ` René Scharfe
2017-07-09 15:14     ` Martin Ågren
2017-07-10  7:27 ` Jeff King
2017-07-10 17:08   ` René Scharfe [this message]
2017-07-11  7:41     ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3f643932-0fe1-26b0-d2bf-a2124a74deca@web.de \
    --to=l.s.r@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).