Replace sort_tu_by_abbrev_offset with operator<
authorTom Tromey <tom@tromey.com>
Mon, 17 May 2021 18:50:33 +0000 (12:50 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 17 May 2021 18:59:40 +0000 (12:59 -0600)
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.

2021-05-17  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
gdb/dwarf2/read.c

index 0014d75fbb83138c69461cd5d9d192a0cbe2ec7a..b4fd2bb69f01ff6fc46b0e84199a8dc591d5299a 100644 (file)
@@ -1,3 +1,9 @@
+2021-05-17  Tom Tromey  <tom@tromey.com>
+
+       * dwarf2/read.c (tu_abbrev_offset::operator<): New method.
+       (sort_tu_by_abbrev_offset): Remove.
+       (build_type_psymtabs): Update.
+
 2021-05-17  Simon Marchi  <simon.marchi@polymtl.ca>
 
        * py-project.toml: New.
index ac786abf6d2363be7836b8e8ef095f40777fbe63..f1bb9b2f3df341e5c30bc18a3c5cab4efa1a7250 100644 (file)
@@ -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;