aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac
diff options
context:
space:
mode:
authorReinier Zwitserloot <r.zwitserloot@projectlombok.org>2019-03-25 20:20:16 +0100
committerReinier Zwitserloot <r.zwitserloot@projectlombok.org>2019-03-25 20:20:22 +0100
commitf8857fdffec01b15a67ca6aad60a1f614fa278e2 (patch)
tree812d46176d8325fb2b1d4a5bb1798470ffd1c5c6 /src/core/lombok/javac
parentcddd9d96ca7afb965c1b4971006360aaac65e8dd (diff)
downloadlombok-f8857fdffec01b15a67ca6aad60a1f614fa278e2.tar.gz
lombok-f8857fdffec01b15a67ca6aad60a1f614fa278e2.tar.bz2
lombok-f8857fdffec01b15a67ca6aad60a1f614fa278e2.zip
[performance] improve typeMatches lookup. Especially in light of the built-in copyable annotations lists growing, this should help performance.
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index f08098d2..095d1c7a 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -298,9 +298,14 @@ public class JavacHandlerUtil {
* @param typeNode A type reference to check.
*/
public static boolean typeMatches(String type, JavacNode node, JCTree typeNode) {
- String typeName = typeNode.toString();
-
- TypeResolver resolver = new TypeResolver(node.getImportList());
+ String typeName = typeNode == null ? null : typeNode.toString();
+ if (typeName == null || typeName.length() == 0) return false;
+ int lastIndexA = typeName.lastIndexOf('.') + 1;
+ int lastIndexB = type.lastIndexOf('.') + 1;
+ int len = typeName.length() - lastIndexA;
+ if (len != type.length() - lastIndexB) return false;
+ for (int i = 0; i < len; i++) if (typeName.charAt(i + lastIndexA) != type.charAt(i + lastIndexB)) return false;
+ TypeResolver resolver = node.getImportListAsTypeResolver();
return resolver.typeMatches(node, type, typeName);
}