Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / d3 / e5611f1a2c1a0100e3e28b546a4ff0784d8d07
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 798AD431FB5\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
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\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 UHkH5suiNxas 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
18         [18.9.25.15])\r
19         by olra.theworths.org (Postfix) with ESMTP id 9A005431FB6\r
20         for <notmuch@notmuchmail.org>; Sun, 30 Jan 2011 20:24:35 -0800 (PST)\r
21 X-AuditID: 1209190f-b7c1dae000000a2b-fe-4d4639831bdf\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
23         by dmz-mailsec-scanner-4.mit.edu (Symantec Brightmail Gateway) with\r
24         SMTP id 24.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-2.mit.edu (8.13.8/8.9.2) with ESMTP id p0V4OZKK015393; \r
27         Sun, 30 Jan 2011 23:24:35 -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 p0V4OYC8007256\r
33         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
34         Sun, 30 Jan 2011 23:24:34 -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 1PjlJa-000445-11; Sun, 30 Jan 2011 23:24:34 -0500\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH 2/2] Simplify _notmuch_doc_id_set_init interface.\r
41 Date: Sun, 30 Jan 2011 23:22:33 -0500\r
42 Message-Id: <1296447753-10109-3-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
50 Precedence: list\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
61 \r
62 Don't require the caller of _notmuch_doc_id_set_init to pass in a\r
63 correct bound; instead compute it from the array.  This simplifies the\r
64 caller and makes this interface easier to use correctly.\r
65 ---\r
66  lib/query.cc |   17 +++++++++--------\r
67  1 files changed, 9 insertions(+), 8 deletions(-)\r
68 \r
69 diff --git a/lib/query.cc b/lib/query.cc\r
70 index c155470..07e695b 100644\r
71 --- a/lib/query.cc\r
72 +++ b/lib/query.cc\r
73 @@ -260,17 +260,20 @@ _notmuch_mset_messages_move_to_next (notmuch_messages_t *messages)\r
74  static notmuch_bool_t\r
75  _notmuch_doc_id_set_init (void *ctx,\r
76                           notmuch_doc_id_set_t *doc_ids,\r
77 -                         GArray *arr, unsigned int bound)\r
78 +                         GArray *arr)\r
79  {\r
80 -    size_t count = (bound + sizeof (doc_ids->bitmap[0]) - 1) /\r
81 -       sizeof (doc_ids->bitmap[0]);\r
82 -    unsigned int *bitmap = talloc_zero_array (ctx, unsigned int, count);\r
83 +    unsigned int max = 0;\r
84 +    unsigned int *bitmap;\r
85 +\r
86 +    for (unsigned int i = 0; i < arr->len; i++)\r
87 +       max = MAX(max, g_array_index (arr, unsigned int, i));\r
88 +    bitmap = talloc_zero_array (ctx, unsigned int, 1 + max / sizeof (*bitmap));\r
89  \r
90      if (bitmap == NULL)\r
91         return FALSE;\r
92  \r
93      doc_ids->bitmap = bitmap;\r
94 -    doc_ids->bound = bound;\r
95 +    doc_ids->bound = max + 1;\r
96  \r
97      for (unsigned int i = 0; i < arr->len; i++) {\r
98         unsigned int doc_id = g_array_index (arr, unsigned int, i);\r
99 @@ -315,7 +318,6 @@ notmuch_query_search_threads (notmuch_query_t *query)\r
100  {\r
101      notmuch_threads_t *threads;\r
102      notmuch_messages_t *messages;\r
103 -    Xapian::docid max_doc_id = 0;\r
104  \r
105      threads = talloc (query, notmuch_threads_t);\r
106      if (threads == NULL)\r
107 @@ -335,7 +337,6 @@ notmuch_query_search_threads (notmuch_query_t *query)\r
108      while (notmuch_messages_valid (messages)) {\r
109         unsigned int doc_id = _notmuch_mset_messages_get_doc_id (messages);\r
110         g_array_append_val (threads->doc_ids, doc_id);\r
111 -       max_doc_id = MAX (max_doc_id, doc_id);\r
112         notmuch_messages_move_to_next (messages);\r
113      }\r
114      threads->doc_id_pos = 0;\r
115 @@ -343,7 +344,7 @@ notmuch_query_search_threads (notmuch_query_t *query)\r
116      talloc_free (messages);\r
117  \r
118      if (! _notmuch_doc_id_set_init (threads, &threads->match_set,\r
119 -                                   threads->doc_ids, max_doc_id + 1)) {\r
120 +                                   threads->doc_ids)) {\r
121         talloc_free (threads);\r
122         return NULL;\r
123      }\r
124 -- \r
125 1.7.2.3\r
126 \r