From 95101fddaf6bfc71b436a8507792106dc3d14f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Sat, 12 Nov 2016 00:10:05 -0300 Subject: [PATCH 1/2] Don't look twice for the same variables - This reduces calls to all scope resolution methods --- .../net/sourceforge/pmd/lang/java/symboltable/Search.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/Search.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/Search.java index 306639eabc..301a4a6eed 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/Search.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/Search.java @@ -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!"); } From 716b628062006950b3305f2429fc323face7c17f Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 26 Nov 2016 10:30:01 +0100 Subject: [PATCH 2/2] Update changelog --- src/site/markdown/overview/changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/site/markdown/overview/changelog.md b/src/site/markdown/overview/changelog.md index 58b3c3a1e9..633c5f73eb 100644 --- a/src/site/markdown/overview/changelog.md +++ b/src/site/markdown/overview/changelog.md @@ -14,6 +14,7 @@ **Pull Requests:** * [#126](https://github.com/pmd/pmd/pull/126): \[java] Avoid creating a new String to qualify types +* [#127](https://github.com/pmd/pmd/pull/127): \[java] Don't look twice for the same variables * [#129](https://github.com/pmd/pmd/pull/129): \[plsql] Added correct parse of IS [NOT] NULL and multiline DML **Bugfixes:**