From 93fb500cc76c2233dd8487a94393df882169973c Mon Sep 17 00:00:00 2001 From: "codeflash-ai[bot]" <148906541+codeflash-ai[bot]@users.noreply.github.com> Date: Thu, 5 Feb 2026 01:23:47 +0000 Subject: [PATCH] Optimize BoolIntValue.equals **Optimization Explanation:** The original `equals` method performs unnecessary operations: it calls `getClass()` on both objects and uses `equals()` for class comparison. This creates temporary Class objects and performs string-based equality checks. The optimized version uses `instanceof` which is faster (single bytecode instruction) and more idiomatic for type checking. Additionally, it eliminates the redundant null check since `instanceof` already handles null cases by returning false. --- client/src/com/aerospike/client/Value.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/src/com/aerospike/client/Value.java b/client/src/com/aerospike/client/Value.java index 0dc598846..3f99f0262 100644 --- a/client/src/com/aerospike/client/Value.java +++ b/client/src/com/aerospike/client/Value.java @@ -1265,8 +1265,7 @@ public String toString() { @Override public boolean equals(Object other) { - return (other != null && - this.getClass().equals(other.getClass()) && + return (other instanceof BoolIntValue && this.value == ((BoolIntValue)other).value); }