From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id A5D0F3853825 for ; Mon, 17 May 2021 16:13:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A5D0F3853825 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 14HGDFfK006695 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 May 2021 12:13:19 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 14HGDFfK006695 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 11FBF1E54D; Mon, 17 May 2021 12:13:15 -0400 (EDT) Subject: Re: [PATCH] Replace sort_tu_by_abbrev_offset with operator< To: Tom Tromey , gdb-patches@sourceware.org References: <20210515151915.990795-1-tom@tromey.com> From: Simon Marchi Message-ID: <6a50bee3-1c1e-356e-ab68-5e101baf10d3@polymtl.ca> Date: Mon, 17 May 2021 12:13:14 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210515151915.990795-1-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 17 May 2021 16:13:15 +0000 X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 May 2021 16:13:22 -0000 On 2021-05-15 11:19 a.m., Tom Tromey wrote: > I noticed that sort_tu_by_abbrev_offset only has a single caller. It > seemed simpler to replace it with an implementation of operator< > instead. > > gdb/ChangeLog > 2021-05-15 Tom Tromey > > * dwarf2/read.c (tu_abbrev_offset::operator<): New method. > (sort_tu_by_abbrev_offset): Remove. > (build_type_psymtabs): Update. > --- > gdb/ChangeLog | 6 ++++++ > gdb/dwarf2/read.c | 18 +++++++----------- > 2 files changed, 13 insertions(+), 11 deletions(-) > > diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c > index ac786abf6d2..f1bb9b2f3df 100644 > --- a/gdb/dwarf2/read.c > +++ b/gdb/dwarf2/read.c > @@ -7351,19 +7351,16 @@ struct tu_abbrev_offset > : sig_type (sig_type_), abbrev_offset (abbrev_offset_) > {} > > + /* This is used when sorting. */ > + bool operator< (const tu_abbrev_offset &other) > + { > + return abbrev_offset < other.abbrev_offset; > + } > + > signatured_type *sig_type; > sect_offset abbrev_offset; > }; > > -/* Helper routine for build_type_psymtabs, passed to std::sort. */ > - > -static bool > -sort_tu_by_abbrev_offset (const struct tu_abbrev_offset &a, > - const struct tu_abbrev_offset &b) > -{ > - return a.abbrev_offset < b.abbrev_offset; > -} > - > /* Efficiently read all the type units. > > The efficiency is because we sort TUs by the abbrev table they use and > @@ -7431,8 +7428,7 @@ build_type_psymtabs (dwarf2_per_objfile *per_objfile) > } > } > > - std::sort (sorted_by_abbrev.begin (), sorted_by_abbrev.end (), > - sort_tu_by_abbrev_offset); > + std::sort (sorted_by_abbrev.begin (), sorted_by_abbrev.end ()); > > abbrev_offset = (sect_offset) ~(unsigned) 0; > > LGTM, thanks. Simon