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
|
||||||
@ -267,4 +273,4 @@ public class Hash extends DataStructureImpl {
|
|||||||
}
|
}
|
||||||
_log.debug("Fill check test passed");
|
_log.debug("Fill check test passed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
@ -100,4 +106,4 @@ public class PrivateKey extends DataStructureImpl {
|
|||||||
return KeyGenerator.getPublicKey(this);
|
return KeyGenerator.getPublicKey(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
@ -94,4 +100,4 @@ public class PublicKey extends DataStructureImpl {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
@ -152,4 +152,4 @@ public class RouterAddress extends DataStructureImpl {
|
|||||||
buf.append("]");
|
buf.append("]");
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
@ -140,4 +142,4 @@ public class RouterIdentity extends DataStructureImpl {
|
|||||||
__calculatedHash = SHA256Generator.getInstance().calculateHash(identBytes);
|
__calculatedHash = SHA256Generator.getInstance().calculateHash(identBytes);
|
||||||
return __calculatedHash;
|
return __calculatedHash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
@ -98,4 +104,4 @@ public class SessionKey extends DataStructureImpl {
|
|||||||
buf.append("]");
|
buf.append("]");
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
@ -83,4 +89,4 @@ public class Signature extends DataStructureImpl {
|
|||||||
buf.append("]");
|
buf.append("]");
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
@ -96,4 +102,4 @@ public class SigningPrivateKey extends DataStructureImpl {
|
|||||||
public SigningPublicKey toPublic() {
|
public SigningPublicKey toPublic() {
|
||||||
return KeyGenerator.getSigningPublicKey(this);
|
return KeyGenerator.getSigningPublicKey(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
@ -88,4 +94,4 @@ public class SigningPublicKey extends DataStructureImpl {
|
|||||||
buf.append("]");
|
buf.append("]");
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user