qsort: tc-xtensa.c tidy
Not much to see here, just reduce the number of calls to S_GET_VALUE and symbol_symbolS in the comparison functions. * config/tc-xtensa.c (xg_order_trampoline_chain_entry): Don't call S_GET_VALUE multiple times for a symbol. Rearrange code so it is obvious what is the primary sort key. (xg_order_trampoline_chain): Similarly.
This commit is contained in:
parent
d9f06fca19
commit
8ef6decbc1
2 changed files with 33 additions and 22 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2019-10-16 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
* config/tc-xtensa.c (xg_order_trampoline_chain_entry): Don't
|
||||||
|
call S_GET_VALUE multiple times for a symbol. Rearrange code
|
||||||
|
so it is obvious what is the primary sort key.
|
||||||
|
(xg_order_trampoline_chain): Similarly.
|
||||||
|
|
||||||
2019-10-15 Alan Modra <amodra@gmail.com>
|
2019-10-15 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* config/tc-nds32.c (nds32_set_section_relocs): Use relocs and n
|
* config/tc-nds32.c (nds32_set_section_relocs): Use relocs and n
|
||||||
|
|
|
@ -7584,14 +7584,17 @@ static int xg_order_trampoline_chain_entry (const void *a, const void *b)
|
||||||
const struct trampoline_chain_entry *pa = a;
|
const struct trampoline_chain_entry *pa = a;
|
||||||
const struct trampoline_chain_entry *pb = b;
|
const struct trampoline_chain_entry *pb = b;
|
||||||
|
|
||||||
if (pa->sym == pb->sym ||
|
if (pa->sym != pb->sym)
|
||||||
S_GET_VALUE (pa->sym) == S_GET_VALUE (pb->sym))
|
{
|
||||||
if (pa->offset == pb->offset)
|
valueT aval = S_GET_VALUE (pa->sym);
|
||||||
return 0;
|
valueT bval = S_GET_VALUE (pb->sym);
|
||||||
else
|
|
||||||
return pa->offset < pb->offset ? -1 : 1;
|
if (aval != bval)
|
||||||
else
|
return aval < bval ? -1 : 1;
|
||||||
return S_GET_VALUE (pa->sym) < S_GET_VALUE (pb->sym) ? -1 : 1;
|
}
|
||||||
|
if (pa->offset != pb->offset)
|
||||||
|
return pa->offset < pb->offset ? -1 : 1;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xg_sort_trampoline_chain (struct trampoline_chain *tc)
|
static void xg_sort_trampoline_chain (struct trampoline_chain *tc)
|
||||||
|
@ -7674,23 +7677,24 @@ static int xg_order_trampoline_chain (const void *a, const void *b)
|
||||||
const struct trampoline_chain_entry *pb = &_pb->target;
|
const struct trampoline_chain_entry *pb = &_pb->target;
|
||||||
symbolS *s1 = pa->sym;
|
symbolS *s1 = pa->sym;
|
||||||
symbolS *s2 = pb->sym;
|
symbolS *s2 = pb->sym;
|
||||||
symbolS *tmp;
|
|
||||||
|
|
||||||
tmp = symbol_symbolS (s1);
|
if (s1 != s2)
|
||||||
if (tmp)
|
{
|
||||||
s1 = tmp;
|
symbolS *tmp = symbol_symbolS (s1);
|
||||||
|
if (tmp)
|
||||||
|
s1 = tmp;
|
||||||
|
|
||||||
tmp = symbol_symbolS (s2);
|
tmp = symbol_symbolS (s2);
|
||||||
if (tmp)
|
if (tmp)
|
||||||
s2 = tmp;
|
s2 = tmp;
|
||||||
|
|
||||||
if (s1 == s2)
|
if (s1 != s2)
|
||||||
if (pa->offset == pb->offset)
|
return s1 < s2 ? -1 : 1;
|
||||||
return 0;
|
}
|
||||||
else
|
|
||||||
return pa->offset < pb->offset ? -1 : 1;
|
if (pa->offset != pb->offset)
|
||||||
else
|
return pa->offset < pb->offset ? -1 : 1;
|
||||||
return s1 < s2 ? -1 : 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct trampoline_chain *
|
static struct trampoline_chain *
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue