From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 75009 invoked by alias); 19 Jun 2017 09:26:33 -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 74945 invoked by uid 89); 19 Jun 2017 09:26:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:1341 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 19 Jun 2017 09:26:29 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9CABC80C11 for ; Mon, 19 Jun 2017 09:26:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9CABC80C11 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9CABC80C11 Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74A1D88EE2; Mon, 19 Jun 2017 09:26:30 +0000 (UTC) Subject: Re: [PATCH 2/6] Code cleanup: dwarf2read.c: Eliminate ::file_write To: Jan Kratochvil References: <8efc0742-1014-4fe0-6948-f40a9c5c4975@redhat.com> <1497284051-13795-2-git-send-email-palves@redhat.com> <20170617173443.GA17084@host1.jankratochvil.net> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: Date: Mon, 19 Jun 2017 09:26:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20170617173443.GA17084@host1.jankratochvil.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-06/txt/msg00497.txt.bz2 On 06/17/2017 06:34 PM, Jan Kratochvil wrote: > On Mon, 12 Jun 2017 18:14:07 +0200, Pedro Alves wrote: >> There's no real need for all this indirection. > >> - ::file_write (file, m_vec); >> + if (::fwrite (m_vec.data (), 1, m_vec.size (), file) != m_vec.size ()) >> + error (_("couldn't write data to file")); > > Aren't 28 characters with the variable mentioned once easier to write and more > bug-proof than to write each time 115 characters That's not a correct comparison, because you're not accounting for all the characters of the wrapper functions there were removed. If you count those, then certainly we end up with fewer characters overall. It might be different if the wrapper functions were used in more than one place, but they aren't. > mentioning the same variable 3 times? The old code mentioned the same variable 3 times as well: -template -static void -file_write (FILE *file, const std::vector &vec) -{ - file_write (file, vec.data (), vec.size() * sizeof (vec[0])); ^^^ ^^^ ^^^ -} I ran into this because with the byte_vector change, we'd have to to modify this template's template parameter and prototype. So the extra indirection ended up getting in the way, and it's much simpler to just get rid of it. Thanks, Pedro Alves