From 356835f3e289b82c1eb26e8f13f226c198a7640f Mon Sep 17 00:00:00 2001 From: "codeflash-ai[bot]" <148906541+codeflash-ai[bot]@users.noreply.github.com> Date: Wed, 4 Mar 2026 09:22:15 +0000 Subject: [PATCH] Optimize Filter.geoWithinRegionByIndex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change reduces runtime by 11% (11.6 μs → 10.4 μs) by calling Value.get(region) once and reusing that Value for both begin and end instead of creating two Value objects. Reusing the single Value eliminates one method call and one object allocation per Filter construction, cutting per-invocation CPU and allocation overhead on the hot path. Trade-off: begin and end now share the same Value instance (i.e., object identity is aliased), which is appropriate for the effectively immutable Value type and produced no measurable test regressions while slightly lowering memory churn. --- client/src/com/aerospike/client/query/Filter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/src/com/aerospike/client/query/Filter.java b/client/src/com/aerospike/client/query/Filter.java index 77e7da056..df1ff4274 100644 --- a/client/src/com/aerospike/client/query/Filter.java +++ b/client/src/com/aerospike/client/query/Filter.java @@ -435,7 +435,8 @@ public static Filter geoWithinRegion(Expression exp, IndexCollectionType type, S * @return filter instance */ public static Filter geoWithinRegionByIndex(String indexName, IndexCollectionType type, String region) { - return new Filter(indexName, null, type, ParticleType.GEOJSON, Value.get(region), Value.get(region)); + Value v = Value.get(region); + return new Filter(indexName, null, type, ParticleType.GEOJSON, v, v); } /**