diff options
author | Christoph Dreis <christoph.dreis@freenet.de> | 2023-02-21 08:27:05 +0100 |
---|---|---|
committer | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2023-03-22 12:36:28 +0100 |
commit | e051df91a0571676c6230215bdebe23360289994 (patch) | |
tree | 80b085e34a0e5d6b0a7343251e20627fdbbbddda | |
parent | 02fe21f27c4dce1fd7525f2da5bdf5d66ff19f7b (diff) | |
download | lombok-e051df91a0571676c6230215bdebe23360289994.tar.gz lombok-e051df91a0571676c6230215bdebe23360289994.tar.bz2 lombok-e051df91a0571676c6230215bdebe23360289994.zip |
Reduce allocations from JavacHandlerUtil.typeMatches()
-rw-r--r-- | src/core/lombok/javac/handlers/JavacHandlerUtil.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index 9c6e0f84..78c7caf5 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -1735,6 +1735,26 @@ public class JavacHandlerUtil { * Searches the given field node for annotations that are in the given list, and returns those. */ private static List<JCAnnotation> findAnnotationsInList(JavacNode node, java.util.List<String> annotationsToFind) { + JCAnnotation anno = null; + String annoName = null; + for (JavacNode child : node.down()) { + if (child.getKind() == Kind.ANNOTATION) { + if (anno != null) { + annoName = ""; + break; + } + JCAnnotation annotation = (JCAnnotation) child.get(); + annoName = annotation.annotationType.toString(); + anno = annotation; + } + } + + if (annoName == null) return List.nil(); + + if (!annoName.isEmpty()) { + for (String bn : annotationsToFind) if (typeMatches(bn, node, annoName)) return List.of(anno); + } + ListBuffer<JCAnnotation> result = new ListBuffer<JCAnnotation>(); for (JavacNode child : node.down()) { if (child.getKind() == Kind.ANNOTATION) { |