From 2917a8c5e15d79aebfb461fa7db8d54665afd0ae Mon Sep 17 00:00:00 2001 From: Rawi01 Date: Fri, 19 Jun 2020 17:32:26 +0200 Subject: Cache absolute file location --- src/core/lombok/javac/JavacAST.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/core/lombok/javac') 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 { 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 { } @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) { -- cgit