[review] Replace some more qsort calls with std::sort

Tom Tromey (Code Review)
2019-10-18T13:47:10Z

Tom Tromey has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/131
......................................................................

Patch Set 1:

(8 comments)

Thank you for the patch. This is a nice improvement.

I found a few nits, but nothing serious.

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/131/1/gdb/breakpoint.c
File gdb/breakpoint.c:

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/131/1/gdb/breakpoint.c@522
PS1, Line 522: /* Array is sorted by bp_location_is_less_than - primarily by the ADDRESS. */
In gerrit I can't tell if this line is overlong.
If it is, it should wrap.

It would be nice if we could add column guides to gerrit.

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/131/1/gdb/breakpoint.c@11440
PS1, Line 11440: return (a->address > b->address) < (a->address < b->address);
I think this can just be a->address < b->address ?

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/131/1/gdb/breakpoint.c@11448
PS1, Line 11448: < (a->pspace->num < b->pspace->num));
Likewise this can be simplified.

BTW gerrit doesn't seem to allow multi-line selections... bummer.

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/131/1/gdb/breakpoint.c@11452
PS1, Line 11452: return (a->permanent < b->permanent) < (a->permanent > b->permanent);
Ditto.

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/131/1/gdb/breakpoint.c@11460
PS1, Line 11460: < (a->owner->number < b->owner->number));
Ditto.

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/131/1/gdb/breakpoint.c@11462
PS1, Line 11462: return (a > b) < (a < b);
Even here.

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/131/1/gdb/disasm.c
File gdb/disasm.c:

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/131/1/gdb/disasm.c@184
PS1, Line 184: val = mle1.start_pc - mle2.start_pc;
This code is a bit weird. It only works because "val" has signed type,
as start_pc is unsigned. I think it would be a lot clearer to just
change this to use plain < instead of subtraction.

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/131/1/gdb/mdebugread.c
File gdb/mdebugread.c:

https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/131/1/gdb/mdebugread.c@4570
PS1, Line 4570: addr_diff = (BLOCK_START (b1)) - (BLOCK_START (b2));
This has the same oddity involving signs. I think just using the
obvious comparisons would be better.