From 1ad6b08056a4ed8281bb3a36263b5a5b27e09512 Mon Sep 17 00:00:00 2001 From: Daniel Sun Date: Sun, 12 Jan 2025 02:24:53 +0900 Subject: [PATCH] Trivial tweak: set initial capacity --- .../codehaus/groovy/runtime/metaclass/ClosureMetaClass.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/codehaus/groovy/runtime/metaclass/ClosureMetaClass.java b/src/main/java/org/codehaus/groovy/runtime/metaclass/ClosureMetaClass.java index 04585f83c69..ffd574e3835 100644 --- a/src/main/java/org/codehaus/groovy/runtime/metaclass/ClosureMetaClass.java +++ b/src/main/java/org/codehaus/groovy/runtime/metaclass/ClosureMetaClass.java @@ -145,9 +145,10 @@ public Object chooseMethod(final Class[] arguments, final boolean coerce) { } else if (arguments.length == 1 && arguments[0] == null) { return MetaClassHelper.chooseMostGeneralMethodWith1NullParam(methods); } else { - List matchingMethods = new ArrayList(); final Object[] data = methods.getArray(); - for (int i = 0, n = methods.size(); i < n; i += 1) { + final int length = data.length; + List matchingMethods = new ArrayList(length); + for (int i = 0; i < length; i += 1) { Object method = data[i]; // making this false helps find matches