From: David Bremner Date: Sat, 27 Dec 2014 08:33:49 +0000 (+0100) Subject: [PATCH] lib: collapse computation of directory_id into a single expression X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d598451562632c052fb09e45b126a73ecc2facb3;p=notmuch-archives.git [PATCH] lib: collapse computation of directory_id into a single expression --- diff --git a/87/563ec161d49f0ec879d5a228793ea1aa045349 b/87/563ec161d49f0ec879d5a228793ea1aa045349 new file mode 100644 index 000000000..adb7f6721 --- /dev/null +++ b/87/563ec161d49f0ec879d5a228793ea1aa045349 @@ -0,0 +1,86 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id C861B431FDB + for ; Sat, 27 Dec 2014 01:08:23 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 6fSGTsoKQtv8 for ; + Sat, 27 Dec 2014 01:08:20 -0800 (PST) +Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155]) + (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id A1D6A431FAF + for ; Sat, 27 Dec 2014 01:08:20 -0800 (PST) +Received: from remotemail by yantan.tethera.net with local (Exim 4.80) + (envelope-from ) + id 1Y4nMB-0004S7-MJ; Sat, 27 Dec 2014 05:08:19 -0400 +Received: (nullmailer pid 24499 invoked by uid 1000); Sat, 27 Dec 2014 + 08:33:59 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: [PATCH] lib: collapse computation of directory_id into a single + expression +Date: Sat, 27 Dec 2014 09:33:49 +0100 +Message-Id: <1419669229-24454-1-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.1.3 +In-Reply-To: <20141226113755.GA64154@pamparam> +References: <20141226113755.GA64154@pamparam> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 27 Dec 2014 09:08:23 -0000 + +According to id:20141226113755.GA64154@pamparam , the lifetime +of (*i).c_str is only guaranteed for that line, so we extract the +information we need in the same line. +--- + lib/message.cc | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +diff --git a/lib/message.cc b/lib/message.cc +index a7a13cc..14e60af 100644 +--- a/lib/message.cc ++++ b/lib/message.cc +@@ -639,7 +639,7 @@ _notmuch_message_add_directory_terms (void *ctx, notmuch_message_t *message) + + for (i.skip_to (direntry_prefix); i != message->doc.termlist_end (); i++) { + unsigned int directory_id; +- const char *direntry, *directory; ++ const char *directory; + char *colon; + + /* Terminate loop at first term without desired prefix. */ +@@ -649,10 +649,9 @@ _notmuch_message_add_directory_terms (void *ctx, notmuch_message_t *message) + /* Indicate that there are filenames remaining. */ + status = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID; + +- direntry = (*i).c_str (); +- direntry += direntry_prefix_len; +- +- directory_id = strtol (direntry, &colon, 10); ++ directory_id = ++ strtol ((*i).c_str () + direntry_prefix_len, ++ &colon, 10); + + if (colon == NULL || *colon != ':') + INTERNAL_ERROR ("malformed direntry"); +-- +2.1.3 +