From: Jani Nikula Date: Fri, 2 Jan 2015 17:52:55 +0000 (+0200) Subject: Re: [PATCH] lib: convert two "iterator copy strings" into references. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f1f570ecb341a74e15ac02664ee2861258a4156c;p=notmuch-archives.git Re: [PATCH] lib: convert two "iterator copy strings" into references. --- diff --git a/b9/bee2e374c3dc134df7962cc38cb40be112b28d b/b9/bee2e374c3dc134df7962cc38cb40be112b28d new file mode 100644 index 000000000..830aa7228 --- /dev/null +++ b/b9/bee2e374c3dc134df7962cc38cb40be112b28d @@ -0,0 +1,113 @@ +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 914C4431FAF + for ; Fri, 2 Jan 2015 09:52:53 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 107YemJ5X4cX for ; + Fri, 2 Jan 2015 09:52:50 -0800 (PST) +Received: from mail-wg0-f53.google.com (mail-wg0-f53.google.com + [74.125.82.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 221EC431FAE for ; Fri, 2 Jan 2015 09:52:50 -0800 + (PST) +Received: by mail-wg0-f53.google.com with SMTP id x13so6647061wgg.12 + for ; Fri, 02 Jan 2015 09:52:49 -0800 (PST) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:subject:in-reply-to:references + :user-agent:date:message-id:mime-version:content-type; + bh=yblz8LTxZGxCXv6C3KfPPK0L5CHPGBJbVsXKsgSJbCw=; + b=KfD/tmddy/mnSbGaJvEQ4qu0EHql5XS2KKsqcX7G7OqWw/rS4zevdFoaYIWuMJidBW + SfVRWnoBpy/Qqtk6R+XKSQMAnZz6O4NR/bKA/z3/x6WsDp9p6vwQdDtmn8a+CMMQuOCe + TzEH7mWAIj//90xFsNpwk2dmrsQAqal2KUeqeQhtv9FdM2jzccJ/0Ie+MbcQSV6poQls + BvchnCOggz5CgynriJJk/X8FfjE4qWzoWnraPVBc7Os0rrd7LZHQgKWgW9jn+LB+HDgx + c8MF/IWFrFQcXxfC6c59TOyFWBrmN+IK5n7zHezWm6WiumpaEEWwHRT6YVlxOxwWG3+5 + o1eA== +X-Gm-Message-State: + ALoCoQmrdhH9VNIn1rKp4O4nBgyO3HCURTpCKMpQvYou4445YeF6y4m2wzcDd3YU8rYF/hlSCrgu +X-Received: by 10.180.83.42 with SMTP id n10mr106979123wiy.54.1420221169007; + Fri, 02 Jan 2015 09:52:49 -0800 (PST) +Received: from localhost (mobile-internet-bceeb5-193.dhcp.inet.fi. + [188.238.181.193]) + by mx.google.com with ESMTPSA id s9sm54861597wiz.12.2015.01.02.09.52.47 + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Fri, 02 Jan 2015 09:52:48 -0800 (PST) +From: Jani Nikula +To: David Bremner , notmuch@notmuchmail.org +Subject: Re: [PATCH] lib: convert two "iterator copy strings" into references. +In-Reply-To: <1420215652-4131-1-git-send-email-david@tethera.net> +References: <1419763508-11902-1-git-send-email-david@tethera.net> + <1420215652-4131-1-git-send-email-david@tethera.net> +User-Agent: Notmuch/0.19+6~gf2e3d2c (http://notmuchmail.org) Emacs/24.4.1 + (x86_64-pc-linux-gnu) +Date: Fri, 02 Jan 2015 19:52:55 +0200 +Message-ID: <871tnd1348.fsf@nikula.org> +MIME-Version: 1.0 +Content-Type: text/plain +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: Fri, 02 Jan 2015 17:52:53 -0000 + +On Fri, 02 Jan 2015, David Bremner wrote: +> Apparently this is a supported and even idiomatic way of keeping a +> temporary object (e.g. like that returned from an operator +> dereference) alive. +> --- +> +> I decided it was better to do both of these "keepalive" strings the +> same way, so I applied the parent patch as is. + +LGTM. + +> +> lib/message.cc | 4 ++-- +> 1 file changed, 2 insertions(+), 2 deletions(-) +> +> diff --git a/lib/message.cc b/lib/message.cc +> index bacb4d4..956a70a 100644 +> --- a/lib/message.cc +> +++ b/lib/message.cc +> @@ -283,7 +283,7 @@ _notmuch_message_get_term (notmuch_message_t *message, +> if (i == end) +> return NULL; +> +> - std::string term = *i; +> + const std::string &term = *i; +> if (strncmp (term.c_str(), prefix, prefix_len)) +> return NULL; +> +> @@ -641,7 +641,7 @@ _notmuch_message_add_directory_terms (void *ctx, notmuch_message_t *message) +> unsigned int directory_id; +> const char *direntry, *directory; +> char *colon; +> - const std::string term = *i; +> + const std::string &term = *i; +> +> /* Terminate loop at first term without desired prefix. */ +> if (strncmp (term.c_str (), direntry_prefix, direntry_prefix_len)) +> -- +> 2.1.3 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch