* symbol.c (gfc_find_gsymbol): Simplify, don't unconditionally
descend into all branches.
From-SVN: r123355
+2007-03-30 Tobias Schlüter <tobi@gcc.gnu.org>
+
+ * symbol.c (gfc_find_gsymbol): Simplify, don't unconditionally
+ descend into all branches.
+
2007-03-29 Tobias Schlüter <tobi@gcc.gnu.org>
* intrinsic.c (conv_name): Let gfc_get_string handle the format.
gfc_gsymbol *
gfc_find_gsymbol (gfc_gsymbol *symbol, const char *name)
{
- gfc_gsymbol *s;
+ int c;
if (symbol == NULL)
return NULL;
- if (strcmp (symbol->name, name) == 0)
- return symbol;
- s = gfc_find_gsymbol (symbol->left, name);
- if (s != NULL)
- return s;
+ while (symbol)
+ {
+ c = strcmp (name, symbol->name);
+ if (!c)
+ return symbol;
- s = gfc_find_gsymbol (symbol->right, name);
- if (s != NULL)
- return s;
+ symbol = (c < 0) ? symbol->left : symbol->right;
+ }
return NULL;
}