Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / 87 / 563ec161d49f0ec879d5a228793ea1aa045349
1 Return-Path: <bremner@tesseract.cs.unb.ca>\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 C861B431FDB\r
6         for <notmuch@notmuchmail.org>; Sat, 27 Dec 2014 01:08:23 -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 6fSGTsoKQtv8 for <notmuch@notmuchmail.org>;\r
16         Sat, 27 Dec 2014 01:08:20 -0800 (PST)\r
17 Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])\r
18         (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id A1D6A431FAF\r
21         for <notmuch@notmuchmail.org>; Sat, 27 Dec 2014 01:08:20 -0800 (PST)\r
22 Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
23         (envelope-from <bremner@tesseract.cs.unb.ca>)\r
24         id 1Y4nMB-0004S7-MJ; Sat, 27 Dec 2014 05:08:19 -0400\r
25 Received: (nullmailer pid 24499 invoked by uid 1000); Sat, 27 Dec 2014\r
26         08:33:59 -0000\r
27 From: David Bremner <david@tethera.net>\r
28 To: notmuch@notmuchmail.org\r
29 Subject: [PATCH] lib: collapse computation of directory_id into a single\r
30         expression\r
31 Date: Sat, 27 Dec 2014 09:33:49 +0100\r
32 Message-Id: <1419669229-24454-1-git-send-email-david@tethera.net>\r
33 X-Mailer: git-send-email 2.1.3\r
34 In-Reply-To: <20141226113755.GA64154@pamparam>\r
35 References: <20141226113755.GA64154@pamparam>\r
36 X-BeenThere: notmuch@notmuchmail.org\r
37 X-Mailman-Version: 2.1.13\r
38 Precedence: list\r
39 List-Id: "Use and development of the notmuch mail system."\r
40         <notmuch.notmuchmail.org>\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
42         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
44 List-Post: <mailto:notmuch@notmuchmail.org>\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
48 X-List-Received-Date: Sat, 27 Dec 2014 09:08:23 -0000\r
49 \r
50 According to id:20141226113755.GA64154@pamparam , the lifetime\r
51 of (*i).c_str is only guaranteed for that line, so we extract the\r
52 information we need in the same line.\r
53 ---\r
54  lib/message.cc | 9 ++++-----\r
55  1 file changed, 4 insertions(+), 5 deletions(-)\r
56 \r
57 diff --git a/lib/message.cc b/lib/message.cc\r
58 index a7a13cc..14e60af 100644\r
59 --- a/lib/message.cc\r
60 +++ b/lib/message.cc\r
61 @@ -639,7 +639,7 @@ _notmuch_message_add_directory_terms (void *ctx, notmuch_message_t *message)\r
62  \r
63      for (i.skip_to (direntry_prefix); i != message->doc.termlist_end (); i++) {\r
64         unsigned int directory_id;\r
65 -       const char *direntry, *directory;\r
66 +       const char *directory;\r
67         char *colon;\r
68  \r
69         /* Terminate loop at first term without desired prefix. */\r
70 @@ -649,10 +649,9 @@ _notmuch_message_add_directory_terms (void *ctx, notmuch_message_t *message)\r
71         /* Indicate that there are filenames remaining. */\r
72         status = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;\r
73  \r
74 -       direntry = (*i).c_str ();\r
75 -       direntry += direntry_prefix_len;\r
76 -\r
77 -       directory_id = strtol (direntry, &colon, 10);\r
78 +       directory_id =\r
79 +           strtol ((*i).c_str () + direntry_prefix_len,\r
80 +                   &colon, 10);\r
81  \r
82         if (colon == NULL || *colon != ':')\r
83             INTERNAL_ERROR ("malformed direntry");\r
84 -- \r
85 2.1.3\r
86 \r