Skip to content

Commit da79d62

Browse files
committed
gas symbol_remove
If a symbol is at the start of the symbol chain then symbol_rootP points at the symbol and symbol->x->previous is NULL. Testing either condition is sufficient, there is no need to test both. Similarly for the symbol at the end of the symbol chain. I'm testing the previous/next pointer because it's most likely that the symbol is not at the start/finish of the chain and thus we need to use that pointer. * symbols.c (symbol_remove): Tidy list handling. (symbol_append, symbol_clone, symbol_insert): Likewise.
1 parent 5e5f37e commit da79d62

File tree

1 file changed

+18
-41
lines changed

1 file changed

+18
-41
lines changed

gas/symbols.c

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -812,17 +812,14 @@ symbol_clone (symbolS *orgsymP, int replace)
812812

813813
if (replace)
814814
{
815-
if (symbol_rootP == orgsymP)
815+
if (orgsymP->x->previous != NULL)
816+
orgsymP->x->previous->x->next = newsymP;
817+
else
816818
symbol_rootP = newsymP;
817-
else if (orgsymP->x->previous)
818-
{
819-
orgsymP->x->previous->x->next = newsymP;
820-
orgsymP->x->previous = NULL;
821-
}
822-
if (symbol_lastP == orgsymP)
823-
symbol_lastP = newsymP;
824-
else if (orgsymP->x->next)
819+
if (orgsymP->x->next != NULL)
825820
orgsymP->x->next->x->previous = newsymP;
821+
else
822+
symbol_lastP = newsymP;
826823

827824
/* Symbols that won't be output can't be external. */
828825
S_CLEAR_EXTERNAL (orgsymP);
@@ -1033,17 +1030,12 @@ symbol_append (symbolS *addme, symbolS *target,
10331030
*rootPP = addme;
10341031
*lastPP = addme;
10351032
return;
1036-
} /* if the list is empty */
1033+
}
10371034

10381035
if (target->x->next != NULL)
1039-
{
1040-
target->x->next->x->previous = addme;
1041-
}
1036+
target->x->next->x->previous = addme;
10421037
else
1043-
{
1044-
know (*lastPP == target);
1045-
*lastPP = addme;
1046-
} /* if we have a next */
1038+
*lastPP = addme;
10471039

10481040
addme->x->next = target->x->next;
10491041
target->x->next = addme;
@@ -1071,25 +1063,15 @@ symbol_remove (symbolS *symbolP, symbolS **rootPP, symbolS **lastPP)
10711063
if (symbolP->flags.local_symbol)
10721064
abort ();
10731065

1074-
if (symbolP == *rootPP)
1075-
{
1076-
*rootPP = symbolP->x->next;
1077-
} /* if it was the root */
1078-
1079-
if (symbolP == *lastPP)
1080-
{
1081-
*lastPP = symbolP->x->previous;
1082-
} /* if it was the tail */
1066+
if (symbolP->x->previous != NULL)
1067+
symbolP->x->previous->x->next = symbolP->x->next;
1068+
else
1069+
*rootPP = symbolP->x->next;
10831070

10841071
if (symbolP->x->next != NULL)
1085-
{
1086-
symbolP->x->next->x->previous = symbolP->x->previous;
1087-
} /* if not last */
1088-
1089-
if (symbolP->x->previous != NULL)
1090-
{
1091-
symbolP->x->previous->x->next = symbolP->x->next;
1092-
} /* if not first */
1072+
symbolP->x->next->x->previous = symbolP->x->previous;
1073+
else
1074+
*lastPP = symbolP->x->previous;
10931075

10941076
debug_verify_symchain (*rootPP, *lastPP);
10951077
}
@@ -1109,14 +1091,9 @@ symbol_insert (symbolS *addme, symbolS *target,
11091091
abort ();
11101092

11111093
if (target->x->previous != NULL)
1112-
{
1113-
target->x->previous->x->next = addme;
1114-
}
1094+
target->x->previous->x->next = addme;
11151095
else
1116-
{
1117-
know (*rootPP == target);
1118-
*rootPP = addme;
1119-
} /* if not first */
1096+
*rootPP = addme;
11201097

11211098
addme->x->previous = target->x->previous;
11221099
target->x->previous = addme;

0 commit comments

Comments
 (0)