Don't look twice for the same variables

- This reduces calls to all scope resolution methods
This commit is contained in:
Juan Martín Sotuyo Dodero
2016-11-12 00:10:05 -03:00
committed by Andreas Dangel
parent c88c1a02d4
commit 95101fddaf

View File

@ -47,13 +47,14 @@ public class Search {
if (TRACE) {
System.out.println(" checking scope " + scope + " for name occurrence " + nameOccurrence);
}
if (!scope.contains(nameOccurrence) && scope.getParent() != null) {
final boolean isInScope = scope.contains(nameOccurrence);
if (!isInScope && scope.getParent() != null) {
if (TRACE) {
System.out.println(" moving up from " + scope + " to " + scope.getParent());
}
return searchUpward(nameOccurrence, scope.getParent());
}
if (scope.contains(nameOccurrence)) {
if (isInScope) {
if (TRACE) {
System.out.println(" found it!");
}