Skip to content

Commit

Permalink
Reduce allocations from JavacHandlerUtil.typeMatches()
Browse files Browse the repository at this point in the history
  • Loading branch information
dreis2211 authored and rzwitserloot committed Mar 22, 2023
1 parent 02fe21f commit e051df9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/core/lombok/javac/handlers/JavacHandlerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,26 @@ public static List<JCAnnotation> findCopyableToBuilderSingularSetterAnnotations(
* 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) {
Expand Down

0 comments on commit e051df9

Please sign in to comment.