speed up data hashcodes
This commit is contained in:
@ -137,10 +137,12 @@ public class Destination extends DataStructureImpl {
|
|||||||
&& DataHelper.eq(getPublicKey(), dst.getPublicKey());
|
&& DataHelper.eq(getPublicKey(), dst.getPublicKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** the public key has enough randomness in it to use it by itself for speed */
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return DataHelper.hashCode(getCertificate()) + DataHelper.hashCode(getSigningPublicKey())
|
if (_publicKey == null)
|
||||||
+ DataHelper.hashCode(getPublicKey());
|
return 0;
|
||||||
|
return _publicKey.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -147,9 +147,15 @@ public class Hash extends DataStructureImpl {
|
|||||||
return DataHelper.eq(_data, ((Hash) obj)._data);
|
return DataHelper.eq(_data, ((Hash) obj)._data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** a Hash is a hash, so just use the first 4 bytes for speed */
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return DataHelper.hashCode(_data);
|
int rv = 0;
|
||||||
|
if (_data != null) {
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
rv ^= (_data[i] << (i*8));
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -345,12 +345,12 @@ public class LeaseSet extends DataStructureImpl {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** the destination has enough randomness in it to use it by itself for speed */
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return DataHelper.hashCode(getEncryptionKey()) +
|
if (_destination == null)
|
||||||
//(int)_version +
|
return 0;
|
||||||
DataHelper.hashCode(_leases) + DataHelper.hashCode(getSignature())
|
return _destination.hashCode();
|
||||||
+ DataHelper.hashCode(getSigningKey()) + DataHelper.hashCode(getDestination());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -70,9 +70,15 @@ public class PrivateKey extends DataStructureImpl {
|
|||||||
return DataHelper.eq(_data, ((PrivateKey) obj)._data);
|
return DataHelper.eq(_data, ((PrivateKey) obj)._data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** the key has enough randomness in it, use the first 4 bytes for speed */
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return DataHelper.hashCode(_data);
|
int rv = 0;
|
||||||
|
if (_data != null) {
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
rv ^= (_data[i] << (i*8));
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -72,9 +72,15 @@ public class PublicKey extends DataStructureImpl {
|
|||||||
return DataHelper.eq(_data, ((PublicKey) obj)._data);
|
return DataHelper.eq(_data, ((PublicKey) obj)._data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** the key has enough randomness in it, use the first 4 bytes for speed */
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return DataHelper.hashCode(_data);
|
int rv = 0;
|
||||||
|
if (_data != null) {
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
rv ^= (_data[i] << (i*8));
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -130,10 +130,10 @@ public class RouterAddress extends DataStructureImpl {
|
|||||||
&& DataHelper.eq(getTransportStyle(), addr.getTransportStyle());
|
&& DataHelper.eq(getTransportStyle(), addr.getTransportStyle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** the style should be sufficient, for speed */
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return getCost() + DataHelper.hashCode(getTransportStyle()) + DataHelper.hashCode(getExpiration())
|
return DataHelper.hashCode(getTransportStyle());
|
||||||
+ DataHelper.hashCode(getOptions());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -101,10 +101,12 @@ public class RouterIdentity extends DataStructureImpl {
|
|||||||
&& DataHelper.eq(getPublicKey(), ident.getPublicKey());
|
&& DataHelper.eq(getPublicKey(), ident.getPublicKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** the public key has enough randomness in it to use it by itself for speed */
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return DataHelper.hashCode(getCertificate()) + DataHelper.hashCode(getSigningPublicKey())
|
if (_publicKey == null)
|
||||||
+ DataHelper.hashCode(getPublicKey());
|
return 0;
|
||||||
|
return _publicKey.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -76,9 +76,15 @@ public class SessionKey extends DataStructureImpl {
|
|||||||
return DataHelper.eq(_data, ((SessionKey) obj)._data);
|
return DataHelper.eq(_data, ((SessionKey) obj)._data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** the key has enough randomness in it, use the first 4 bytes for speed */
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return DataHelper.hashCode(_data);
|
int rv = 0;
|
||||||
|
if (_data != null) {
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
rv ^= (_data[i] << (i*8));
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -62,9 +62,15 @@ public class Signature extends DataStructureImpl {
|
|||||||
return DataHelper.eq(_data, ((Signature) obj)._data);
|
return DataHelper.eq(_data, ((Signature) obj)._data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** the sig has enough randomness in it, use the first 4 bytes for speed */
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return DataHelper.hashCode(_data);
|
int rv = 0;
|
||||||
|
if (_data != null) {
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
rv ^= (_data[i] << (i*8));
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -68,9 +68,15 @@ public class SigningPrivateKey extends DataStructureImpl {
|
|||||||
return DataHelper.eq(_data, ((SigningPrivateKey) obj)._data);
|
return DataHelper.eq(_data, ((SigningPrivateKey) obj)._data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** the key has enough randomness in it, use the first 4 bytes for speed */
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return DataHelper.hashCode(_data);
|
int rv = 0;
|
||||||
|
if (_data != null) {
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
rv ^= (_data[i] << (i*8));
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -67,9 +67,15 @@ public class SigningPublicKey extends DataStructureImpl {
|
|||||||
return DataHelper.eq(_data, ((SigningPublicKey) obj)._data);
|
return DataHelper.eq(_data, ((SigningPublicKey) obj)._data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** the key has enough randomness in it, use the first 4 bytes for speed */
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return DataHelper.hashCode(_data);
|
int rv = 0;
|
||||||
|
if (_data != null) {
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
rv ^= (_data[i] << (i*8));
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user