aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorTobias Schlüter <tobi@gcc.gnu.org>2007-03-30 01:54:22 +0200
committerTobias Schlüter <tobi@gcc.gnu.org>2007-03-30 01:54:22 +0200
commit1a54978869b510d5b712778ae5e32521459f3791 (patch)
treeb2697eaefba649bcb7efb7fb9ace72180ef60577 /gcc/fortran
parent58c114673775c1240de8e20d430fdacd2eb10061 (diff)
downloadgcc-1a54978869b510d5b712778ae5e32521459f3791.zip
gcc-1a54978869b510d5b712778ae5e32521459f3791.tar.gz
gcc-1a54978869b510d5b712778ae5e32521459f3791.tar.bz2
symbol.c (gfc_find_gsymbol): Simplify, don't unconditionally descend into all branches.
* symbol.c (gfc_find_gsymbol): Simplify, don't unconditionally descend into all branches. From-SVN: r123355
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog5
-rw-r--r--gcc/fortran/symbol.c17
2 files changed, 13 insertions, 9 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 69364bc..ddb515b 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,8 @@
+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.
diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
index 7bf9aec..b1c5ea3 100644
--- a/gcc/fortran/symbol.c
+++ b/gcc/fortran/symbol.c
@@ -2770,20 +2770,19 @@ gfc_symbol_state(void) {
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;
}