Skip to content

Commit

Permalink
Improve equals performance on Address (#8013)
Browse files Browse the repository at this point in the history
* Improve equals performance operation on Address
* Use toArrayUnsafe instead of toArray to reduce GC overhead

Signed-off-by: Ameziane H. <[email protected]>
Co-authored-by: Sally MacFarlane <[email protected]>
  • Loading branch information
ahamlat and macfarla authored Dec 11, 2024
1 parent 657efff commit c62cd21
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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;
Expand Down Expand Up @@ -291,4 +292,16 @@ public Hash addressHash() {
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());
}
}

0 comments on commit c62cd21

Please sign in to comment.