From: Tomi Ollila Date: Fri, 2 Jan 2015 20:07:38 +0000 (+0200) Subject: Re: [PATCH] lib: convert two "iterator copy strings" into references. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b23028cbfa1c2396dfd733f23106682632f58933;p=notmuch-archives.git Re: [PATCH] lib: convert two "iterator copy strings" into references. --- diff --git a/6a/1cc48ade3fea5cabd28e9368cdf8a9f3e13dd3 b/6a/1cc48ade3fea5cabd28e9368cdf8a9f3e13dd3 new file mode 100644 index 000000000..c7799e950 --- /dev/null +++ b/6a/1cc48ade3fea5cabd28e9368cdf8a9f3e13dd3 @@ -0,0 +1,101 @@ +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 2FE71431FAF + for ; Fri, 2 Jan 2015 12:08:09 -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 bpuvSRvRJSAi for ; + Fri, 2 Jan 2015 12:08:06 -0800 (PST) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id D1512431FAE + for ; Fri, 2 Jan 2015 12:08:05 -0800 (PST) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id BA780100051; + Fri, 2 Jan 2015 22:07:38 +0200 (EET) +From: Tomi Ollila +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~g8725b09 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +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 20:08:09 -0000 + +On Fri, Jan 02 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. +> --- + +Based on internet search with words 'c++ reference to temporary' (*) +I believe the change is working one. + +Tomi + +(*) Uh, reading those explations gives me a headache >;) + +> +> I decided it was better to do both of these "keepalive" strings the +> same way, so I applied the parent patch as is. +> +> 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