You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2026/02/16 00:19:33 UTC
(groovy) 02/02: GROOVY-10307: address review feedback
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 61dae3df5433c7eb0c0442baf5fce2b917220232
Author: James Fredley <ja...@users.noreply.github.com>
AuthorDate: Sun Feb 15 18:46:49 2026 -0500
GROOVY-10307: address review feedback
---
.../jmh/groovy/org/apache/groovy/perf/ClosureBench.groovy | 2 +-
.../jmh/groovy/org/apache/groovy/perf/OperatorBench.groovy | 1 +
.../org/apache/groovy/perf/PropertyAccessBench.groovy | 13 +++++++------
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/ClosureBench.groovy b/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/ClosureBench.groovy
index 4e83c3ad57..654dde3c57 100644
--- a/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/ClosureBench.groovy
+++ b/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/ClosureBench.groovy
@@ -69,7 +69,7 @@ class ClosureBench {
*/
@Benchmark
void benchmarkClosureMultiParams(Blackhole bh) {
- Closure c = { a, b, c -> a + b + c }
+ Closure c = { a, b, x -> a + b + x }
int sum = 0
for (int i = 0; i < ITERATIONS; i++) {
sum += c(i, i + 1, i + 2)
diff --git a/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/OperatorBench.groovy b/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/OperatorBench.groovy
index 1484aa9b46..349f081ef4 100644
--- a/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/OperatorBench.groovy
+++ b/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/OperatorBench.groovy
@@ -52,6 +52,7 @@ class OperatorBench {
/**
* Integer multiplication — dispatches to Integer.multiply(Integer).
+ * Uses modulo to keep operands small and avoid overflow to zero.
*/
@Benchmark
void integerMultiply(Blackhole bh) {
diff --git a/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/PropertyAccessBench.groovy b/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/PropertyAccessBench.groovy
index 0b45b44384..8ac15e5c0a 100644
--- a/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/PropertyAccessBench.groovy
+++ b/subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/PropertyAccessBench.groovy
@@ -47,7 +47,8 @@ class PropertyAccessBench {
void setBackingField(int value) { _backingField = value }
/**
- * Read/write a public field — the simplest property access path.
+ * Read/write a Groovy property — in Groovy, {@code int instanceField}
+ * declares a property backed by a private field with generated getter/setter.
*/
@Benchmark
void fieldReadWrite(Blackhole bh) {
@@ -89,8 +90,8 @@ class PropertyAccessBench {
}
/**
- * Map-style property access using bracket notation —
- * tests Groovy's map-like property access on a POGO.
+ * Map bracket notation — {@code map['key']} dispatches to
+ * {@code Map.getAt()} / {@code Map.putAt()}.
*/
@Benchmark
void mapStyleAccess(Blackhole bh) {
@@ -119,14 +120,14 @@ class PropertyAccessBench {
/**
* Chained property access — tests multiple property resolutions
- * in a single expression.
+ * in a single expression using nested maps.
*/
@Benchmark
void chainedPropertyAccess(Blackhole bh) {
- List<String> list = ["hello", "world"]
+ Map<String, Object> root = [level1: [level2: [value: 42]]]
int sum = 0
for (int i = 0; i < ITERATIONS; i++) {
- sum += list.first().length()
+ sum += root.level1.level2.value
}
bh.consume(sum)
}