From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 110828 invoked by alias); 24 Jan 2017 19:14:42 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 109585 invoked by uid 89); 24 Jan 2017 19:14:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=H*f:sk:558e1e5, Hx-languages-length:1378, superfluous, H*i:sk:79c06db X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 24 Jan 2017 19:14:40 +0000 Received: by simark.ca (Postfix, from userid 33) id 75E5D1E166; Tue, 24 Jan 2017 14:14:38 -0500 (EST) To: Pedro Alves Subject: Re: [PATCH v2 5/5] Eliminate make_cleanup_ui_file_delete / make ui_file a class hierarchy X-PHP-Originating-Script: 33:rcube.php MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 24 Jan 2017 19:14:00 -0000 From: Simon Marchi Cc: gdb-patches@sourceware.org In-Reply-To: <79c06dbccef0c33309d208316be207f4@polymtl.ca> References: <1484617147-2506-1-git-send-email-palves@redhat.com> <1484617147-2506-6-git-send-email-palves@redhat.com> <5533317a1fdb2e5f36e64731aef84993@polymtl.ca> <4a6cce94-1533-36e9-6015-330e2e014a98@redhat.com> <558e1e55-23eb-716e-8117-c18d7bded7b8@redhat.com> <79c06dbccef0c33309d208316be207f4@polymtl.ca> Message-ID: <4ced996ee1ea0ceef2ec994afeca6bb7@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.2.3 X-IsSubscribed: yes X-SW-Source: 2017-01/txt/msg00504.txt.bz2 On 2017-01-24 13:29, Simon Marchi wrote: >> @@ -420,22 +412,20 @@ c_compute_program (struct compile_instance >> *inst, >> ? "&" : "")); >> break; >> default: >> - fputs_unfiltered (input, buf); >> + buf.puts (input); >> break; >> } >> >> - fputs_unfiltered ("\n", buf); >> + buf.puts ("\n"); >> >> /* For larger user expressions the automatic semicolons may be >> confusing. */ >> if (strchr (input, '\n') == NULL) >> - fputs_unfiltered (";\n", buf); >> + buf.puts (";\n"); >> >> if (inst->scope != COMPILE_I_RAW_SCOPE) >> - fputs_unfiltered ("}\n", buf); >> + buf.puts ("}\n"); >> >> - add_code_footer (inst->scope, buf); >> - code = ui_file_as_string (buf); >> - do_cleanups (cleanup); >> - return code; >> + add_code_footer (inst->scope, &buf); >> + return std::move (buf.string ()); > > I would have thought that this std::move would be superfluous, because > the compiler would do it anyway. Is it the case? Is it a good > practice to use move explicitly to make sure it's a move and not a > copy (and probably get a compile-time error if a move is not > possible)? Oh, I guess it's because buf.string() returns a reference and not a string directly. Otherwise, then I guess the compiler could have done some return value optimization (look at me, using words I don't understand).