This is an automated email from the ASF dual-hosted git repository.
paulk-asert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new b092f36815 GROOVY-12044: CurriedClosure per-element allocation
b092f36815 is described below
commit b092f36815bddafca7e4f82e890f39929664bd79
Author: Paul King <[email protected]>
AuthorDate: Fri May 29 19:32:28 2026 +1000
GROOVY-12044: CurriedClosure per-element allocation
---
.../codehaus/groovy/runtime/CurriedClosure.java | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/src/main/java/org/codehaus/groovy/runtime/CurriedClosure.java
b/src/main/java/org/codehaus/groovy/runtime/CurriedClosure.java
index e614b827f1..9f972b3390 100644
--- a/src/main/java/org/codehaus/groovy/runtime/CurriedClosure.java
+++ b/src/main/java/org/codehaus/groovy/runtime/CurriedClosure.java
@@ -108,6 +108,28 @@ public final class CurriedClosure<V> extends Closure<V> {
//--------------------------------------------------------------------------
+ /**
+ * Fast path for the dominant rcurry/curry shape — one curried argument
and a
+ * single incoming argument against a binary owner. Skips the wrapping
+ * {@code Object[1]} that {@link Closure#call(Object)} would otherwise
allocate
+ * before dispatch, leaving just the one combined {@code Object[2]} that
the
+ * underlying call already requires.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public V call(final Object argument) {
+ if (varargType == null
+ && curriedArguments.length == 1
+ && maximumNumberOfParameters == 1
+ && (index == 0 || index == 1)) {
+ Object[] combined = index == 0
+ ? new Object[]{curriedArguments[0], argument}
+ : new Object[]{argument, curriedArguments[0]};
+ return (V) getOwner().call(combined);
+ }
+ return super.call(argument);
+ }
+
public Object[] getUncurriedArguments(final Object... arguments) {
if (isVararg()) {
int normalizedIndex = index < 0 ? index + arguments.length +
curriedArguments.length : index;