Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjkubitz2021-02-12 11:58:04 +0000
committerAndrey Loskutov2021-02-12 18:35:26 +0000
commitdb0505ae83209e88f185623ebb5db1d077ff30f3 (patch)
tree018f2705a1a88ddda2c6a53617ed56857f74e593
parent43b405562eab0627b3e3f3bb9aaa3352beb98d40 (diff)
downloadeclipse.jdt.core-db0505ae83209e88f185623ebb5db1d077ff30f3.tar.gz
eclipse.jdt.core-db0505ae83209e88f185623ebb5db1d077ff30f3.tar.xz
eclipse.jdt.core-db0505ae83209e88f185623ebb5db1d077ff30f3.zip
Creating IPath can cost ~ 1% of build time Change-Id: I773d8fc70096e5ec8debb2da1870455ee4fb5d55 Signed-off-by: jkubitz <jkubitz-eclipse@gmx.de>
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/AccessRule.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathAccessRule.java10
2 files changed, 11 insertions, 3 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/AccessRule.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/AccessRule.java
index d421d2e714..647bc48582 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/AccessRule.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/AccessRule.java
@@ -20,8 +20,8 @@ public class AccessRule {
public static final int IgnoreIfBetter = 0x02000000; // value must be greater than IProblem#ForbiddenReference and DiscouragedReference
- public char[] pattern;
- public int problemId;
+ public final char[] pattern;
+ public final int problemId;
public AccessRule(char[] pattern, int problemId) {
this(pattern, problemId, false);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathAccessRule.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathAccessRule.java
index 50dcdbb386..d4cb0faae8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathAccessRule.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathAccessRule.java
@@ -21,8 +21,12 @@ import org.eclipse.jdt.internal.compiler.env.AccessRule;
public class ClasspathAccessRule extends AccessRule implements IAccessRule {
+ private IPath path;
+
public ClasspathAccessRule(IPath pattern, int kind) {
this(pattern.toString().toCharArray(), toProblemId(kind));
+ // avoid IPath creation (Bug 571159):
+ this.path = pattern;
}
public ClasspathAccessRule(char[] pattern, int problemId) {
@@ -43,7 +47,11 @@ public class ClasspathAccessRule extends AccessRule implements IAccessRule {
@Override
public IPath getPattern() {
- return new Path(new String(this.pattern));
+ if (this.path == null) {
+ // cache the IPath (Bug 571159):
+ this.path = new Path(new String(this.pattern));
+ }
+ return this.path;
}
@Override

Back to the top