Use empty array constants instead of repeatedly creating new ones

Closes gh-35660

Signed-off-by: Kamil Krzywański <kamilkrzywanski01@gmail.com>
Signed-off-by: Kamil Krzywanski <kamilkrzywanski01@gmail.com>
This commit is contained in:
Kamil Krzywanski
2025-10-18 13:36:06 +02:00
committed by Sam Brannen
parent 687bc7652d
commit 948367092c
6 changed files with 19 additions and 8 deletions
@@ -40,6 +40,8 @@ import org.springframework.util.Assert;
*/
final class MergedAnnotationsCollection implements MergedAnnotations {
private static final MergedAnnotation<?> [] EMPTY_ANNOTATIONS = new MergedAnnotation<?>[0];
private final MergedAnnotation<?>[] annotations;
private final AnnotationTypeMappings[] mappings;
@@ -47,7 +49,7 @@ final class MergedAnnotationsCollection implements MergedAnnotations {
private MergedAnnotationsCollection(Collection<MergedAnnotation<?>> annotations) {
Assert.notNull(annotations, "Annotations must not be null");
this.annotations = annotations.toArray(new MergedAnnotation<?>[0]);
this.annotations = annotations.toArray(EMPTY_ANNOTATIONS);
this.mappings = new AnnotationTypeMappings[this.annotations.length];
for (int i = 0; i < this.annotations.length; i++) {
MergedAnnotation<?> annotation = this.annotations[i];