diff options
author | jkubitz | 2021-02-12 11:58:04 +0000 |
---|---|---|
committer | Andrey Loskutov | 2021-02-12 18:35:26 +0000 |
commit | db0505ae83209e88f185623ebb5db1d077ff30f3 (patch) | |
tree | 018f2705a1a88ddda2c6a53617ed56857f74e593 | |
parent | 43b405562eab0627b3e3f3bb9aaa3352beb98d40 (diff) | |
download | eclipse.jdt.core-db0505ae83209e88f185623ebb5db1d077ff30f3.tar.gz eclipse.jdt.core-db0505ae83209e88f185623ebb5db1d077ff30f3.tar.xz eclipse.jdt.core-db0505ae83209e88f185623ebb5db1d077ff30f3.zip |
Bug 571159 - cache IPath in ClasspathAccessRule.getPattern()I20210216-1140I20210216-1030I20210216-0600I20210215-1800I20210215-0700I20210215-0600I20210214-1800I20210214-0600I20210213-1800I20210213-0600I20210212-1840
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.java | 4 | ||||
-rw-r--r-- | org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathAccessRule.java | 10 |
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 |