From: Simon Marchi <simon.marchi@polymtl.ca>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Replace sort_tu_by_abbrev_offset with operator<
Date: Mon, 17 May 2021 12:13:14 -0400 [thread overview]
Message-ID: <6a50bee3-1c1e-356e-ab68-5e101baf10d3@polymtl.ca> (raw)
In-Reply-To: <20210515151915.990795-1-tom@tromey.com>
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 <tom@tromey.com>
>
> * 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
next prev parent reply other threads:[~2021-05-17 16:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-15 15:19 Tom Tromey
2021-05-17 16:13 ` Simon Marchi [this message]
2021-05-19 22:22 ` Vaseeharan Vinayagamoorthy
2021-05-19 23:35 ` John Baldwin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6a50bee3-1c1e-356e-ab68-5e101baf10d3@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).