diff options
author | Rawi01 <Rawi01@users.noreply.github.com> | 2020-06-19 17:32:26 +0200 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2020-06-25 21:36:19 +0200 |
commit | 2917a8c5e15d79aebfb461fa7db8d54665afd0ae (patch) | |
tree | f84aade0feea206d928df12ed7e4fc1f267a9f79 /src/core/lombok/javac | |
parent | 4e359da7cc079c8283f758f464b65f1bcaa78a7b (diff) | |
download | lombok-2917a8c5e15d79aebfb461fa7db8d54665afd0ae.tar.gz lombok-2917a8c5e15d79aebfb461fa7db8d54665afd0ae.tar.bz2 lombok-2917a8c5e15d79aebfb461fa7db8d54665afd0ae.zip |
Cache absolute file location
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r-- | src/core/lombok/javac/JavacAST.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/core/lombok/javac/JavacAST.java b/src/core/lombok/javac/JavacAST.java index bb5cfc61..86ff7646 100644 --- a/src/core/lombok/javac/JavacAST.java +++ b/src/core/lombok/javac/JavacAST.java @@ -79,6 +79,8 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> { private final Log log; private final ErrorLog errorLogger; private final Context context; + private static final URI NOT_CALCULATED_MARKER = URI.create("https://projectlombok.org/not/calculated"); + private URI memoizedAbsoluteFileLocation = NOT_CALCULATED_MARKER; /** * Creates a new JavacAST of the provided Compilation Unit. @@ -102,7 +104,10 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> { } @Override public URI getAbsoluteFileLocation() { - return getAbsoluteFileLocation((JCCompilationUnit) top().get()); + if (memoizedAbsoluteFileLocation == NOT_CALCULATED_MARKER) { + memoizedAbsoluteFileLocation = getAbsoluteFileLocation((JCCompilationUnit) top().get()); + } + return memoizedAbsoluteFileLocation; } public static URI getAbsoluteFileLocation(JCCompilationUnit cu) { |