From f8857fdffec01b15a67ca6aad60a1f614fa278e2 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 25 Mar 2019 20:20:16 +0100 Subject: [performance] improve typeMatches lookup. Especially in light of the built-in copyable annotations lists growing, this should help performance. --- src/core/lombok/core/AST.java | 11 +++++++++-- src/core/lombok/core/LombokNode.java | 9 +++++++++ src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java | 16 ++++++++-------- src/core/lombok/javac/handlers/JavacHandlerUtil.java | 11 ++++++++--- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/core/lombok/core/AST.java b/src/core/lombok/core/AST.java index 78761f46..9f3a471f 100755 --- a/src/core/lombok/core/AST.java +++ b/src/core/lombok/core/AST.java @@ -60,6 +60,7 @@ public abstract class AST, L extends LombokNode, private final String fileName; private final String packageDeclaration; private final ImportList imports; + private TypeResolver importsAsResolver; Map identityDetector = new IdentityHashMap(); private Map nodeMap = new IdentityHashMap(); private boolean changed = false; @@ -112,13 +113,19 @@ public abstract class AST, L extends LombokNode, /** * Return the contents of each non-static import statement on this AST's top (Compilation Unit) node. - * - * Example: "java.util.IOException". */ public final ImportList getImportList() { return imports; } + /** + * Return the contents of each non-static import statement on this AST's top (Compilation Unit) node, packed into a (cached) TypeResolver. + */ + public final TypeResolver getImportListAsTypeResolver() { + if (importsAsResolver != null) return importsAsResolver; + return importsAsResolver = new TypeResolver(getImportList()); + } + /** * Puts the given node in the map so that javac/Eclipse's own internal AST object can be translated to * an AST.Node object. Also registers the object as visited to avoid endless loops. diff --git a/src/core/lombok/core/LombokNode.java b/src/core/lombok/core/LombokNode.java index ae8fd325..843a78f0 100644 --- a/src/core/lombok/core/LombokNode.java +++ b/src/core/lombok/core/LombokNode.java @@ -96,6 +96,15 @@ public abstract class LombokNode, L extends LombokNode