1 Return-Path: <amthrax@drake.mit.edu>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 5FB9B429E20
\r
6 for <notmuch@notmuchmail.org>; Sun, 30 Jan 2011 20:24:36 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id tBqwnMLnEQPl for <notmuch@notmuchmail.org>;
\r
16 Sun, 30 Jan 2011 20:24:35 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 664D4431FB5
\r
20 for <notmuch@notmuchmail.org>; Sun, 30 Jan 2011 20:24:35 -0800 (PST)
\r
21 X-AuditID: 1209190f-b7c1dae000000a2b-fc-4d4639838196
\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])
\r
23 by dmz-mailsec-scanner-4.mit.edu (Symantec Brightmail Gateway) with
\r
24 SMTP id 04.BD.02603.389364D4; Sun, 30 Jan 2011 23:24:35 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id p0V4OYTv015107;
\r
27 Sun, 30 Jan 2011 23:24:34 -0500
\r
28 Received: from drake.mit.edu
\r
29 (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
30 [209.6.116.242]) (authenticated bits=0)
\r
31 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
32 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id p0V4OW4R007254
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Sun, 30 Jan 2011 23:24:33 -0500 (EST)
\r
35 Received: from amthrax by drake.mit.edu with local (Exim 4.72)
\r
36 (envelope-from <amthrax@drake.mit.edu>)
\r
37 id 1PjlJY-00043v-Nr; Sun, 30 Jan 2011 23:24:32 -0500
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH 1/2] Remove code repetition in the doc ID bitmap code.
\r
41 Date: Sun, 30 Jan 2011 23:22:32 -0500
\r
42 Message-Id: <1296447753-10109-2-git-send-email-amdragon@mit.edu>
\r
43 X-Mailer: git-send-email 1.7.2.3
\r
44 In-Reply-To: <8762t8n22a.fsf@yoom.home.cworth.org>
\r
45 References: <8762t8n22a.fsf@yoom.home.cworth.org>
\r
46 X-Brightmail-Tracker: AAAAAA==
\r
47 Cc: amdragon@mit.edu
\r
48 X-BeenThere: notmuch@notmuchmail.org
\r
49 X-Mailman-Version: 2.1.13
\r
51 List-Id: "Use and development of the notmuch mail system."
\r
52 <notmuch.notmuchmail.org>
\r
53 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
54 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
55 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
56 List-Post: <mailto:notmuch@notmuchmail.org>
\r
57 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
58 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
59 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
60 X-List-Received-Date: Mon, 31 Jan 2011 04:24:36 -0000
\r
62 Remove the repeated "sizeof (doc_ids->bitmap[0])" that bothered cworth
\r
63 by instead defining macros to compute the word and bit offset of a
\r
64 given bit in the doc ID set bitmap.
\r
66 lib/query.cc | 14 +++++++-------
\r
67 1 files changed, 7 insertions(+), 7 deletions(-)
\r
69 diff --git a/lib/query.cc b/lib/query.cc
\r
70 index c7ae4ee..c155470 100644
\r
73 @@ -41,6 +41,9 @@ struct _notmuch_doc_id_set {
\r
77 +#define DOCIDSET_WORD(bit) ((bit) / sizeof (unsigned int))
\r
78 +#define DOCIDSET_BIT(bit) ((bit) % sizeof (unsigned int))
\r
80 struct _notmuch_threads {
\r
81 notmuch_query_t *query;
\r
83 @@ -270,9 +273,8 @@ _notmuch_doc_id_set_init (void *ctx,
\r
84 doc_ids->bound = bound;
\r
86 for (unsigned int i = 0; i < arr->len; i++) {
\r
87 - unsigned int doc_id = g_array_index(arr, unsigned int, i);
\r
88 - bitmap[doc_id / sizeof (bitmap[0])] |=
\r
89 - 1 << (doc_id % sizeof (bitmap[0]));
\r
90 + unsigned int doc_id = g_array_index (arr, unsigned int, i);
\r
91 + bitmap[DOCIDSET_WORD(doc_id)] |= 1 << DOCIDSET_BIT(doc_id);
\r
95 @@ -284,8 +286,7 @@ _notmuch_doc_id_set_contains (notmuch_doc_id_set_t *doc_ids,
\r
97 if (doc_id >= doc_ids->bound)
\r
99 - return (doc_ids->bitmap[doc_id / sizeof (doc_ids->bitmap[0])] &
\r
100 - (1 << (doc_id % sizeof (doc_ids->bitmap[0])))) != 0;
\r
101 + return doc_ids->bitmap[DOCIDSET_WORD(doc_id)] & (1 << DOCIDSET_BIT(doc_id));
\r
105 @@ -293,8 +294,7 @@ _notmuch_doc_id_set_remove (notmuch_doc_id_set_t *doc_ids,
\r
106 unsigned int doc_id)
\r
108 if (doc_id < doc_ids->bound)
\r
109 - doc_ids->bitmap[doc_id / sizeof (doc_ids->bitmap[0])] &=
\r
110 - ~(1 << (doc_id % sizeof (doc_ids->bitmap[0])));
\r
111 + doc_ids->bitmap[DOCIDSET_WORD(doc_id)] &= ~(1 << DOCIDSET_BIT(doc_id));
\r
114 /* Glib objects force use to use a talloc destructor as well, (but not
\r