aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-11-04 10:08:41 -0700
committerTom Tromey <tromey@adacore.com>2024-11-04 12:56:57 -0700
commitae2f3fa7581fb59ebbf80f93b7ed75f853f0ba29 (patch)
tree64df805c451ed1b2a6322f09f17ec11d9e3ccf81
parent0b4c9b505757b477be5481f42ac3839a90491ad1 (diff)
downloadgdb-ae2f3fa7581fb59ebbf80f93b7ed75f853f0ba29.zip
gdb-ae2f3fa7581fb59ebbf80f93b7ed75f853f0ba29.tar.gz
gdb-ae2f3fa7581fb59ebbf80f93b7ed75f853f0ba29.tar.bz2
Turn decode_line_2_compare_items into operator<
This rewrites decode_line_2_compare_items to be an operator< on the relevant type. This simplifies the code a little. Reviewed-by: Keith Seitz <keiths@redhat.com>
-rw-r--r--gdb/linespec.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/gdb/linespec.c b/gdb/linespec.c
index d525626..4d8a8c1 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1386,6 +1386,14 @@ struct decode_line_2_item
{
}
+ /* Used for sorting. */
+ bool operator< (const decode_line_2_item &other) const
+ {
+ if (displayform != other.displayform)
+ return displayform < other.displayform;
+ return fullform < other.fullform;
+ }
+
/* The form using symtab_to_fullname. */
std::string fullform;
@@ -1397,18 +1405,6 @@ struct decode_line_2_item
unsigned int selected : 1;
};
-/* Helper for std::sort to sort decode_line_2_item entries by
- DISPLAYFORM and secondarily by FULLFORM. */
-
-static bool
-decode_line_2_compare_items (const decode_line_2_item &a,
- const decode_line_2_item &b)
-{
- if (a.displayform != b.displayform)
- return a.displayform < b.displayform;
- return a.fullform < b.fullform;
-}
-
/* Handle multiple results in RESULT depending on SELECT_MODE. This
will either return normally, throw an exception on multiple
results, or present a menu to the user. On return, the SALS vector
@@ -1456,7 +1452,7 @@ decode_line_2 (struct linespec_state *self,
}
/* Sort the list of method names. */
- std::sort (items.begin (), items.end (), decode_line_2_compare_items);
+ std::sort (items.begin (), items.end ());
/* Remove entries with the same FULLFORM. */
items.erase (std::unique (items.begin (), items.end (),