[PATCH 4/4] Update NEWS for user.other_name
[notmuch-archives.git] / b1 / b9589bf1ba36be2ebf53bfca02e4a2720b53cb
1 Return-Path: <amthrax@awakening.csail.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 0B066431FB6\r
6         for <notmuch@notmuchmail.org>; Thu,  9 Dec 2010 13:05:38 -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 ZSHQ38EDw+G4 for <notmuch@notmuchmail.org>;\r
16         Thu,  9 Dec 2010 13:05:37 -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 7B43C431FB5\r
20         for <notmuch@notmuchmail.org>; Thu,  9 Dec 2010 13:05:37 -0800 (PST)\r
21 X-AuditID: 1209190f-b7c1dae000000a2b-6d-4d014374b292\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 DB.E2.02603.473410D4; Thu,  9 Dec 2010 16:00:36 -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 oB9L0awt030973; \r
27         Thu, 9 Dec 2010 16:00:36 -0500\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id oB9L0YMl010121\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Thu, 9 Dec 2010 16:00:35 -0500 (EST)\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.72)\r
35         (envelope-from <amthrax@awakening.csail.mit.edu>)\r
36         id 1PQnbO-0007Hy-Pf; Thu, 09 Dec 2010 16:00:34 -0500\r
37 From: Austin Clements <amdragon@MIT.EDU>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH 5/5] Add the tag list to the unified message metadata pass.\r
40 Date: Thu,  9 Dec 2010 15:59:56 -0500\r
41 Message-Id: <1291928396-27937-6-git-send-email-amdragon@mit.edu>\r
42 X-Mailer: git-send-email 1.7.2.3\r
43 In-Reply-To: <1291928396-27937-1-git-send-email-amdragon@mit.edu>\r
44 References: <1291928396-27937-1-git-send-email-amdragon@mit.edu>\r
45 X-Brightmail-Tracker: AAAAARbjX5o=\r
46 Cc: Austin Clements <amdragon@mit.edu>\r
47 X-BeenThere: notmuch@notmuchmail.org\r
48 X-Mailman-Version: 2.1.13\r
49 Precedence: list\r
50 List-Id: "Use and development of the notmuch mail system."\r
51         <notmuch.notmuchmail.org>\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
55 List-Post: <mailto:notmuch@notmuchmail.org>\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
58         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
59 X-List-Received-Date: Thu, 09 Dec 2010 21:05:38 -0000\r
60 \r
61 Now each caller of notmuch_message_get_tags only gets a new iterator,\r
62 instead of a whole new list.  In principle this could cause problems\r
63 with iterating while modifying tags, but through the magic of talloc\r
64 references, we keep the old tag list alive even after the cache in the\r
65 message object is invalidated.\r
66 \r
67 This reduces my index search from the 3.102 seconds before the unified\r
68 metadata pass to 1.811 seconds (1.7X faster).  Combined with the\r
69 thread search optimization in b3caef1f0659dac8183441357c8fee500a940889,\r
70 that makes this query 2.5X faster than when I started.\r
71 ---\r
72  lib/message.cc |   32 ++++++++++++++++++++++++--------\r
73  1 files changed, 24 insertions(+), 8 deletions(-)\r
74 \r
75 diff --git a/lib/message.cc b/lib/message.cc\r
76 index adb205f..cc75a71 100644\r
77 --- a/lib/message.cc\r
78 +++ b/lib/message.cc\r
79 @@ -32,6 +32,7 @@ struct _notmuch_message {\r
80      char *message_id;\r
81      char *thread_id;\r
82      char *in_reply_to;\r
83 +    notmuch_string_list_t *tag_list;\r
84      notmuch_string_list_t *filename_term_list;\r
85      notmuch_string_list_t *filename_list;\r
86      char *author;\r
87 @@ -102,6 +103,7 @@ _notmuch_message_create_for_document (const void *talloc_owner,\r
88      message->message_id = NULL;\r
89      message->thread_id = NULL;\r
90      message->in_reply_to = NULL;\r
91 +    message->tag_list = NULL;\r
92      message->filename_term_list = NULL;\r
93      message->filename_list = NULL;\r
94      message->message_file = NULL;\r
95 @@ -293,6 +295,7 @@ _notmuch_message_ensure_metadata (notmuch_message_t *message)\r
96  {\r
97      Xapian::TermIterator i, end;\r
98      const char *thread_prefix = _find_prefix ("thread"),\r
99 +       *tag_prefix = _find_prefix ("tag"),\r
100         *id_prefix = _find_prefix ("id"),\r
101         *filename_prefix = _find_prefix ("file-direntry"),\r
102         *replyto_prefix = _find_prefix ("replyto");\r
103 @@ -311,6 +314,13 @@ _notmuch_message_ensure_metadata (notmuch_message_t *message)\r
104         message->thread_id =\r
105             _notmuch_message_get_term (message, i, end, thread_prefix);\r
106  \r
107 +    /* Get tags */\r
108 +    if (!message->tag_list) {\r
109 +       message->tag_list =\r
110 +           _notmuch_get_terms_with_prefix (message, i, end, tag_prefix);\r
111 +       _notmuch_string_list_sort (message->tag_list);\r
112 +    }\r
113 +\r
114      /* Get id */\r
115      assert (strcmp (thread_prefix, id_prefix) < 0);\r
116      if (!message->message_id)\r
117 @@ -345,6 +355,11 @@ _notmuch_message_invalidate_metadata (notmuch_message_t *message,\r
118         message->thread_id = NULL;\r
119      }\r
120  \r
121 +    if (strcmp ("tag", prefix_name) == 0) {\r
122 +       talloc_unlink (message, message->tag_list);\r
123 +       message->tag_list = NULL;\r
124 +    }\r
125 +\r
126      if (strcmp ("file-direntry", prefix_name) == 0) {\r
127         talloc_free (message->filename_term_list);\r
128         talloc_free (message->filename_list);\r
129 @@ -645,14 +660,14 @@ notmuch_message_get_date (notmuch_message_t *message)\r
130  notmuch_tags_t *\r
131  notmuch_message_get_tags (notmuch_message_t *message)\r
132  {\r
133 -    Xapian::TermIterator i, end;\r
134 -    notmuch_string_list_t *tags;\r
135 -    i = message->doc.termlist_begin();\r
136 -    end = message->doc.termlist_end();\r
137 -    tags = _notmuch_get_terms_with_prefix (message, i, end,\r
138 -                                          _find_prefix ("tag"));\r
139 -    _notmuch_string_list_sort (tags);\r
140 -    return _notmuch_tags_create (message, tags, TRUE);\r
141 +    if (!message->tag_list)\r
142 +       _notmuch_message_ensure_metadata (message);\r
143 +\r
144 +    /* We tell the iterator to add a talloc reference to the\r
145 +     * underlying list, rather than stealing it.  As a result, it's\r
146 +     * possible to modify the message tags while iterating because\r
147 +     * the iterator will keep the current list alive. */\r
148 +    return _notmuch_tags_create (message, message->tag_list, FALSE);\r
149  }\r
150  \r
151  const char *\r
152 @@ -1210,6 +1225,7 @@ notmuch_message_remove_all_tags (notmuch_message_t *message)\r
153      if (! message->frozen)\r
154         _notmuch_message_sync (message);\r
155  \r
156 +    talloc_free (tags);\r
157      return NOTMUCH_STATUS_SUCCESS;\r
158  }\r
159  \r
160 -- \r
161 1.7.2.3\r
162 \r