From: Carl Worth <cworth@cworth.org>
To: Austin Clements <amdragon@MIT.EDU>
Cc: notmuch@notmuchmail.org
Subject: Re: [PATCH] Various small clean-ups to doc ID set code.
Date: Sat, 29 Jan 2011 07:36:13 +1000 [thread overview]
Message-ID: <8762t8n22a.fsf@yoom.home.cworth.org> (raw)
In-Reply-To: <20101208220153.GT2447@mit.edu>
[-- Attachment #1: Type: text/plain, Size: 1757 bytes --]
On Wed, 8 Dec 2010 17:01:53 -0500, Austin Clements <amdragon@MIT.EDU> wrote:
> Remove the repeated "sizeof (doc_ids->bitmap[0])" that bothered cworth
> by instead defining macros to compute the word and bit offset of a
> given bit in the bitmap.
>
> Don't require the caller of _notmuch_doc_id_set_init to pass in a
> correct bound; instead compute it from the array. This simplifies the
> caller and makes this interface easier to use correctly.
...
> +#define BITMAP_WORD(bit) ((bit) / sizeof (unsigned int))
> +#define BITMAP_BIT(bit) ((bit) % sizeof (unsigned int))
These macros look great, they definitely simplify the code.
> _notmuch_doc_id_set_init (void *ctx,
> notmuch_doc_id_set_t *doc_ids,
> - GArray *arr, unsigned int bound)
> + GArray *arr)
...
> + for (unsigned int i = 0; i < arr->len; i++)
> + max = MAX(max, g_array_index (arr, unsigned int, i));
And computing an argument automatically definitely makes the interface
easier to use. So that's good too. But those two changes are independent
so really need to be in separate commits.
> - if (doc_id >= doc_ids->bound)
> + if (doc_id > doc_ids->max)
And this looks really like a *third* independent change to me.
A code change like the above has the chance to introduce (or fix) an
off-by-one bug---or even leave the code effectively unchanged as the
intent is here.
In order to distinguish all of those cases, I'd like to see a change
like this as a minimal change, and described in the commit
message. (Rather than hidden amongst "various cleanups" that are mostly
about replacing some common code with a macro.)
So I'd be happy to see this patch broken up and sent again.
-Carl
--
carl.d.worth@intel.com
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2011-01-28 22:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-17 19:28 [PATCH 3/4] Optimize thread search using matched docid sets Austin Clements
2010-11-18 7:38 ` Austin Clements
2010-12-08 1:20 ` Carl Worth
2010-12-08 1:19 ` Carl Worth
2010-12-08 21:58 ` Austin Clements
2010-12-08 22:01 ` [PATCH] Various small clean-ups to doc ID set code Austin Clements
2011-01-28 21:36 ` Carl Worth [this message]
2011-01-31 4:22 ` [PATCH v2 0/2] Small clean-ups to the " Austin Clements
2011-03-09 23:21 ` Carl Worth
2011-03-10 1:31 ` Austin Clements
2011-01-31 4:22 ` [PATCH 1/2] Remove code repetition in the doc ID bitmap code Austin Clements
2011-01-31 4:22 ` [PATCH 2/2] Simplify _notmuch_doc_id_set_init interface Austin Clements
2011-01-28 21:26 ` [PATCH 3/4] Optimize thread search using matched docid sets Carl Worth
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: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8762t8n22a.fsf@yoom.home.cworth.org \
--to=cworth@cworth.org \
--cc=amdragon@MIT.EDU \
--cc=notmuch@notmuchmail.org \
/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://yhetil.org/notmuch.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).