Improve equals performance on Address (#8013)

* Improve equals performance operation on Address
* Use toArrayUnsafe instead of toArray to reduce GC overhead

Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
This commit is contained in:
ahamlat
2024-12-11 07:18:56 +01:00
committed by GitHub
parent 657effffd4
commit c62cd21cfb

View File

@@ -22,6 +22,7 @@ import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPException;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import java.util.Arrays;
import java.util.concurrent.ExecutionException;
import com.fasterxml.jackson.annotation.JsonCreator;
@@ -291,4 +292,16 @@ public class Address extends DelegatingBytes {
return Hash.hash(this);
}
}
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Address)) {
return false;
}
Address other = (Address) obj;
return Arrays.equals(this.toArrayUnsafe(), other.toArrayUnsafe());
}
}