diff options
author | Christian Biesinger <cbiesinger@google.com> | 2019-10-03 00:36:35 -0500 |
---|---|---|
committer | Christian Biesinger <cbiesinger@google.com> | 2019-10-19 15:45:33 -0500 |
commit | 39ef2f6256737db92f5d60fa201fe0b301bb8100 (patch) | |
tree | 13ff1a57f5ecac08df8f0ecdc2f3544cb4d97564 /gdb/xcoffread.c | |
parent | 18338fcee6c75bf0b41f803b84ae15221676f8cd (diff) | |
download | gdb-39ef2f6256737db92f5d60fa201fe0b301bb8100.zip gdb-39ef2f6256737db92f5d60fa201fe0b301bb8100.tar.gz gdb-39ef2f6256737db92f5d60fa201fe0b301bb8100.tar.bz2 |
Replace some more qsort calls with std::sort
This has better typesafety, avoids a function pointer indirection,
and can benefit from inlining.
gdb/ChangeLog:
2019-10-19 Christian Biesinger <cbiesinger@google.com>
* bcache.c (bcache::print_statistics): Use std::sort instead of qsort.
* breakpoint.c (bp_locations_compare): Rename to...
(bp_location_is_less_than): ...this, and change to std::sort semantics.
(update_global_location_list): Use std::sort instead of qsort.
* buildsym.c (compare_line_numbers): Rename to...
(lte_is_less_than): ...this, and change to std::sort semantics.
(buildsym_compunit::end_symtab_with_blockvector): Use std::sort
instead of qsort.
* disasm.c (compare_lines): Rename to...
(line_is_less_than): ...this, and change to std::sort semantics.
(do_mixed_source_and_assembly_deprecated): Call std::sort instead
of qsort.
* dwarf2-frame.c (qsort_fde_cmp): Rename to...
(fde_is_less_than): ...this, and change to std::sort semantics.
(dwarf2_build_frame_info): Call std::sort instead of qsort.
* mdebugread.c (compare_blocks):
(block_is_less_than): ...this, and change to std::sort semantics.
(sort_blocks): Call std::sort instead of qsort.
* objfiles.c (qsort_cmp): Rename to...
(sort_cmp): ...this, and change to std::sort semantics.
(update_section_map): Call std::sort instead of qsort.
* remote.c (compare_pnums): Remove.
(map_regcache_remote_table): Call std::sort instead of qsort.
* utils.c (compare_positive_ints): Remove.
* utils.h (compare_positive_ints): Remove.
* xcoffread.c (compare_lte): Remove.
(arrange_linetable): Call std::sort instead of qsort.
Change-Id: Ibcddce12a3d07448701e731b7150fa23611d86de
Diffstat (limited to 'gdb/xcoffread.c')
-rw-r--r-- | gdb/xcoffread.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 9378414..bc48773 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -28,6 +28,7 @@ #include <sys/file.h> #endif #include <sys/stat.h> +#include <algorithm> #include "coff/internal.h" #include "libcoff.h" /* FIXME, internal data from BFD */ @@ -234,8 +235,6 @@ static void read_xcoff_symtab (struct objfile *, struct partial_symtab *); static void add_stab_to_list (char *, struct pending_stabs **); #endif -static int compare_lte (const void *, const void *); - static struct linetable *arrange_linetable (struct linetable *); static void record_include_end (struct coff_symbol *); @@ -407,18 +406,6 @@ add_stab_to_list (char *stabname, struct pending_stabs **stabvector) /* *INDENT-ON* */ - -/* compare line table entry addresses. */ - -static int -compare_lte (const void *lte1p, const void *lte2p) -{ - struct linetable_entry *lte1 = (struct linetable_entry *) lte1p; - struct linetable_entry *lte2 = (struct linetable_entry *) lte2p; - - return lte1->pc - lte2->pc; -} - /* Given a line table with function entries are marked, arrange its functions in ascending order and strip off function entry markers and return it in a newly created table. If the old one is good @@ -471,8 +458,9 @@ arrange_linetable (struct linetable *oldLineTb) return oldLineTb; } else if (function_count > 1) - qsort (fentry, function_count, - sizeof (struct linetable_entry), compare_lte); + std::sort (fentry, fentry + function_count, + [] (const linetable_entry <e1, const linetable_entry& lte2) + { return lte1.pc < lte2.pc; }); /* Allocate a new line table. */ newLineTb = (struct linetable *) |