add shortcut in equals() for speed

This commit is contained in:
zzz
2013-01-02 13:27:24 +00:00
parent c8e12b9ac9
commit 8c2ddec400
12 changed files with 12 additions and 0 deletions

View File

@ -66,6 +66,7 @@ public class ByteArray implements Serializable, Comparable {
@Override
public final boolean equals(Object o) {
if (o == this) return true;
if (o == null) return false;
if (o instanceof ByteArray) {
ByteArray ba = (ByteArray)o;

View File

@ -177,6 +177,7 @@ public class Certificate extends DataStructureImpl {
@Override
public boolean equals(Object object) {
if (object == this) return true;
if ((object == null) || !(object instanceof Certificate)) return false;
Certificate cert = (Certificate) object;
return _type == cert.getCertificateType() && DataHelper.eq(_payload, cert.getPayload());

View File

@ -116,6 +116,7 @@ public class DateAndFlags extends DataStructureImpl {
@Override
public boolean equals(Object object) {
if (object == this) return true;
if ((object == null) || !(object instanceof DateAndFlags)) return false;
DateAndFlags daf = (DateAndFlags) object;
return _date == daf._date && _flags == daf._flags;

View File

@ -83,6 +83,7 @@ public class KeysAndCert extends DataStructureImpl {
@Override
public boolean equals(Object object) {
if (object == this) return true;
if ((object == null) || !(object instanceof KeysAndCert)) return false;
KeysAndCert ident = (KeysAndCert) object;
return DataHelper.eq(_certificate, ident._certificate)

View File

@ -137,6 +137,7 @@ public class Lease extends DataStructureImpl {
@Override
public boolean equals(Object object) {
if (object == this) return true;
if ((object == null) || !(object instanceof Lease)) return false;
Lease lse = (Lease) object;
return DataHelper.eq(_end, lse.getEndDate())

View File

@ -324,6 +324,7 @@ public class LeaseSet extends DatabaseEntry {
@Override
public boolean equals(Object object) {
if (object == this) return true;
if ((object == null) || !(object instanceof LeaseSet)) return false;
LeaseSet ls = (LeaseSet) object;
return DataHelper.eq(getEncryptionKey(), ls.getEncryptionKey()) &&

View File

@ -105,6 +105,7 @@ public class Payload extends DataStructureImpl {
@Override
public boolean equals(Object object) {
if (object == this) return true;
if ((object == null) || !(object instanceof Payload)) return false;
Payload p = (Payload) object;
return DataHelper.eq(_unencryptedData, p.getUnencryptedData())

View File

@ -70,6 +70,7 @@ public class PrivateKey extends SimpleDataStructure {
@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if ((obj == null) || !(obj instanceof PrivateKey)) return false;
return DataHelper.eq(_data, ((PrivateKey) obj)._data);
}

View File

@ -225,6 +225,7 @@ public class RouterAddress extends DataStructureImpl {
@Override
public boolean equals(Object object) {
if (object == this) return true;
if ((object == null) || !(object instanceof RouterAddress)) return false;
RouterAddress addr = (RouterAddress) object;
// let's keep this fast as we are putting an address into the RouterInfo set frequently

View File

@ -588,6 +588,7 @@ public class RouterInfo extends DatabaseEntry {
@Override
public boolean equals(Object object) {
if (object == this) return true;
if ((object == null) || !(object instanceof RouterInfo)) return false;
RouterInfo info = (RouterInfo) object;
return DataHelper.eq(_identity, info.getIdentity())

View File

@ -182,6 +182,7 @@ public abstract class SimpleDataStructure extends DataStructureImpl {
*/
@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if ((obj == null) || !(obj instanceof SimpleDataStructure)) return false;
return DataHelper.eq(_data, ((SimpleDataStructure) obj)._data);
}

View File

@ -72,6 +72,7 @@ public class TunnelId extends DataStructureImpl {
@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if ( (obj == null) || !(obj instanceof TunnelId))
return false;
return _tunnelId == ((TunnelId)obj)._tunnelId;