1 Return-Path: <m.walters@qmul.ac.uk>
\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 0F055431FAF
\r
6 for <notmuch@notmuchmail.org>; Sat, 8 Dec 2012 03:22:51 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5
\r
12 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,
\r
13 NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id ap35AObs0HbJ for <notmuch@notmuchmail.org>;
\r
17 Sat, 8 Dec 2012 03:22:50 -0800 (PST)
\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])
\r
19 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 53F7C431FAE
\r
22 for <notmuch@notmuchmail.org>; Sat, 8 Dec 2012 03:22:50 -0800 (PST)
\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])
\r
24 by mail2.qmul.ac.uk with esmtp (Exim 4.71)
\r
25 (envelope-from <m.walters@qmul.ac.uk>)
\r
26 id 1ThIUa-0001Ld-J9; Sat, 08 Dec 2012 11:22:48 +0000
\r
27 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)
\r
28 by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)
\r
29 (envelope-from <m.walters@qmul.ac.uk>)
\r
30 id 1ThIUa-0006lB-67; Sat, 08 Dec 2012 11:22:48 +0000
\r
31 From: Mark Walters <markwalters1009@gmail.com>
\r
32 To: david@tethera.net, notmuch@notmuchmail.org
\r
33 Subject: Re: [Patch v3b 9/9] tag-util: optimization of tag application
\r
34 In-Reply-To: <1354843607-17980-10-git-send-email-david@tethera.net>
\r
35 References: <1354843607-17980-1-git-send-email-david@tethera.net>
\r
36 <1354843607-17980-10-git-send-email-david@tethera.net>
\r
37 User-Agent: Notmuch/0.14+81~g9730584 (http://notmuchmail.org) Emacs/23.4.1
\r
38 (x86_64-pc-linux-gnu)
\r
39 Date: Sat, 08 Dec 2012 11:22:53 +0000
\r
40 Message-ID: <87zk1og54i.fsf@qmul.ac.uk>
\r
42 Content-Type: text/plain; charset=us-ascii
\r
43 X-Sender-Host-Address: 93.97.24.31
\r
44 X-QM-SPAM-Info: Sender has good ham record. :)
\r
45 X-QM-Body-MD5: 2100af87dc12ae39309909ab44db1033 (of first 20000 bytes)
\r
46 X-SpamAssassin-Score: -1.8
\r
47 X-SpamAssassin-SpamBar: -
\r
48 X-SpamAssassin-Report: The QM spam filters have analysed this message to
\r
50 spam. We require at least 5.0 points to mark a message as spam.
\r
51 This message scored -1.8 points.
\r
52 Summary of the scoring:
\r
53 * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,
\r
55 * [138.37.6.40 listed in list.dnswl.org]
\r
56 * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
\r
57 provider * (markwalters1009[at]gmail.com)
\r
58 * 0.5 AWL AWL: From: address is in the auto white-list
\r
59 X-QM-Scan-Virus: ClamAV says the message is clean
\r
60 Cc: David Bremner <bremner@debian.org>
\r
61 X-BeenThere: notmuch@notmuchmail.org
\r
62 X-Mailman-Version: 2.1.13
\r
64 List-Id: "Use and development of the notmuch mail system."
\r
65 <notmuch.notmuchmail.org>
\r
66 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
67 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
68 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
69 List-Post: <mailto:notmuch@notmuchmail.org>
\r
70 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
71 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
72 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
73 X-List-Received-Date: Sat, 08 Dec 2012 11:22:51 -0000
\r
75 On Fri, 07 Dec 2012, david@tethera.net wrote:
\r
76 > From: David Bremner <bremner@debian.org>
\r
78 > The idea is not to bother with restore operations if they don't change
\r
79 > the set of tags. This is actually a relatively common case.
\r
81 > In order to avoid fancy datastructures, this method is quadratic in
\r
82 > the number of tags; at least on my mail database this doesn't seem to
\r
85 > tag-util.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\r
86 > 1 file changed, 66 insertions(+)
\r
88 > diff --git a/tag-util.c b/tag-util.c
\r
89 > index 932ee7f..3d54e9e 100644
\r
92 > @@ -124,6 +124,69 @@ message_error (notmuch_message_t *message,
\r
93 > fprintf (stderr, "Status: %s\n", notmuch_status_to_string (status));
\r
97 > +makes_changes (notmuch_message_t *message,
\r
98 > + tag_op_list_t *list,
\r
99 > + tag_op_flag_t flags)
\r
104 > + notmuch_tags_t *tags;
\r
105 > + notmuch_bool_t changes = FALSE;
\r
107 > + /* First, do we delete an existing tag? */
\r
108 > + changes = FALSE;
\r
109 > + for (tags = notmuch_message_get_tags (message);
\r
110 > + ! changes && notmuch_tags_valid (tags);
\r
111 > + notmuch_tags_move_to_next (tags)) {
\r
112 > + const char *cur_tag = notmuch_tags_get (tags);
\r
113 > + int last_op = (flags & TAG_FLAG_REMOVE_ALL) ? -1 : 0;
\r
115 > + /* slight contortions to count down with an unsigned index */
\r
116 > + for (i = list->count; i-- > 0; /*nothing*/) {
\r
117 > + if (strcmp (cur_tag, list->ops[i].tag) == 0) {
\r
118 > + last_op = list->ops[i].remove ? -1 : 1;
\r
123 I agree that this is a little ugly but ok I think. Is it worth adding a
\r
124 comment as to why you are counting backwards? eg " we count backwards to
\r
125 check whether the last change for the tag foo is removal"
\r
133 > + changes = (last_op == -1);
\r
135 > + notmuch_tags_destroy (tags);
\r
140 > + /* Now check for adding new tags */
\r
141 > + for (i = 0; i < list->count; i++) {
\r
142 > + notmuch_bool_t exists = FALSE;
\r
144 > + if (list->ops[i].remove)
\r
147 > + for (tags = notmuch_message_get_tags (message);
\r
148 > + notmuch_tags_valid (tags);
\r
149 > + notmuch_tags_move_to_next (tags)) {
\r
150 > + const char *cur_tag = notmuch_tags_get (tags);
\r
151 > + if (strcmp (cur_tag, list->ops[i].tag) == 0) {
\r
156 > + notmuch_tags_destroy (tags);
\r
158 > + /* the following test is conservative,
\r
159 > + * in the sense it ignores cases like +foo ... -foo
\r
160 > + * but this is OK from a correctness point of view
\r
170 > tag_op_list_apply (notmuch_message_t *message,
\r
171 > tag_op_list_t *list,
\r
172 > @@ -133,6 +196,9 @@ tag_op_list_apply (notmuch_message_t *message,
\r
173 > notmuch_status_t status = 0;
\r
174 > tag_operation_t *tag_ops = list->ops;
\r
176 > + if (! (flags & TAG_FLAG_PRE_OPTIMIZED) && ! makes_changes (message, list, flags))
\r
177 > + return NOTMUCH_STATUS_SUCCESS;
\r
179 > status = notmuch_message_freeze (message);
\r
181 > message_error (message, status, "freezing message");
\r
185 > _______________________________________________
\r
186 > notmuch mailing list
\r
187 > notmuch@notmuchmail.org
\r
188 > http://notmuchmail.org/mailman/listinfo/notmuch
\r