mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-25 07:42:06 +01:00
core: add shortcut via hash in EqualsUtil
Return false as soon as the hashed value does not match. This is sound, since every class that implements equals(Object) should also implement hashCode().
This commit is contained in:
parent
4f609b855c
commit
c49999b933
1 changed files with 7 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2019 Florian Schmaus.
|
||||
* Copyright 2019-2020 Florian Schmaus.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -34,6 +34,12 @@ public final class EqualsUtil {
|
|||
return false;
|
||||
}
|
||||
|
||||
int thisHashCode = thisObject.hashCode();
|
||||
int otherHashCode = other.hashCode();
|
||||
if (thisHashCode != otherHashCode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EqualsUtil.Builder equalsBuilder = new EqualsUtil.Builder();
|
||||
|
||||
equalsComperator.compare(equalsBuilder, thisObjectClass.cast(other));
|
||||
|
|
Loading…
Reference in a new issue