Skip to content

Commit e051df9

Browse files
dreis2211rzwitserloot
authored andcommitted
Reduce allocations from JavacHandlerUtil.typeMatches()
1 parent 02fe21f commit e051df9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/core/lombok/javac/handlers/JavacHandlerUtil.java

+20
Original file line numberDiff line numberDiff line change
@@ -1735,6 +1735,26 @@ public static List<JCAnnotation> findCopyableToBuilderSingularSetterAnnotations(
17351735
* Searches the given field node for annotations that are in the given list, and returns those.
17361736
*/
17371737
private static List<JCAnnotation> findAnnotationsInList(JavacNode node, java.util.List<String> annotationsToFind) {
1738+
JCAnnotation anno = null;
1739+
String annoName = null;
1740+
for (JavacNode child : node.down()) {
1741+
if (child.getKind() == Kind.ANNOTATION) {
1742+
if (anno != null) {
1743+
annoName = "";
1744+
break;
1745+
}
1746+
JCAnnotation annotation = (JCAnnotation) child.get();
1747+
annoName = annotation.annotationType.toString();
1748+
anno = annotation;
1749+
}
1750+
}
1751+
1752+
if (annoName == null) return List.nil();
1753+
1754+
if (!annoName.isEmpty()) {
1755+
for (String bn : annotationsToFind) if (typeMatches(bn, node, annoName)) return List.of(anno);
1756+
}
1757+
17381758
ListBuffer<JCAnnotation> result = new ListBuffer<JCAnnotation>();
17391759
for (JavacNode child : node.down()) {
17401760
if (child.getKind() == Kind.ANNOTATION) {

0 commit comments

Comments
 (0)