aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
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/eclipse/handlers/EclipseHandlerUtil.java
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/eclipse/handlers/EclipseHandlerUtil.java')
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
index 9439caf3..78b11873 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -221,14 +221,14 @@ public class EclipseHandlerUtil {
* @param typeRef A type reference to check.
*/
public static boolean typeMatches(String type, EclipseNode node, TypeReference typeRef) {
- if (typeRef == null || typeRef.getTypeName() == null || typeRef.getTypeName().length == 0) return false;
- String lastPartA = new String(typeRef.getTypeName()[typeRef.getTypeName().length -1]);
- int lastIndex = type.lastIndexOf('.');
- String lastPartB = lastIndex == -1 ? type : type.substring(lastIndex + 1);
- if (!lastPartA.equals(lastPartB)) return false;
- String typeName = toQualifiedName(typeRef.getTypeName());
-
- TypeResolver resolver = new TypeResolver(node.getImportList());
+ char[][] tn = typeRef == null ? null : typeRef.getTypeName();
+ if (tn == null || tn.length == 0) return false;
+ char[] lastPartA = tn[tn.length - 1];
+ int lastIndex = type.lastIndexOf('.') + 1;
+ if (lastPartA.length != type.length() - lastIndex) return false;
+ for (int i = 0; i < lastPartA.length; i++) if (lastPartA[i] != type.charAt(i + lastIndex)) return false;
+ String typeName = toQualifiedName(tn);
+ TypeResolver resolver = node.getImportListAsTypeResolver();
return resolver.typeMatches(node, type, typeName);
}