Changeset 7736545f


Ignore:
Timestamp:
Aug 27, 2009 3:53:41 AM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
4bc5215
Parents:
1ecf437
Message:

speed up data hashcodes

Location:
core/java/src/net/i2p/data
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/data/Destination.java

    r1ecf437 r7736545f  
    138138    }
    139139   
     140    /** the public key has enough randomness in it to use it by itself for speed */
    140141    @Override
    141142    public int hashCode() {
    142         return DataHelper.hashCode(getCertificate()) + DataHelper.hashCode(getSigningPublicKey())
    143                + DataHelper.hashCode(getPublicKey());
     143        if (_publicKey == null)
     144            return 0;
     145        return _publicKey.hashCode();
    144146    }
    145147   
  • core/java/src/net/i2p/data/Hash.java

    r1ecf437 r7736545f  
    148148    }
    149149   
     150    /** a Hash is a hash, so just use the first 4 bytes for speed */
    150151    @Override
    151152    public int hashCode() {
    152         return DataHelper.hashCode(_data);
     153        int rv = 0;
     154        if (_data != null) {
     155            for (int i = 0; i < 4; i++)
     156                rv ^= (_data[i] << (i*8));
     157        }
     158        return rv;
    153159    }
    154160   
  • core/java/src/net/i2p/data/LeaseSet.java

    r1ecf437 r7736545f  
    346346    }
    347347   
     348    /** the destination has enough randomness in it to use it by itself for speed */
    348349    @Override
    349350    public int hashCode() {
    350         return DataHelper.hashCode(getEncryptionKey()) +
    351         //(int)_version +
    352                DataHelper.hashCode(_leases) + DataHelper.hashCode(getSignature())
    353                + DataHelper.hashCode(getSigningKey()) + DataHelper.hashCode(getDestination());
     351        if (_destination == null)
     352            return 0;
     353        return _destination.hashCode();
    354354    }
    355355   
  • core/java/src/net/i2p/data/PrivateKey.java

    r1ecf437 r7736545f  
    7171    }
    7272   
     73    /** the key has enough randomness in it, use the first 4 bytes for speed */
    7374    @Override
    7475    public int hashCode() {
    75         return DataHelper.hashCode(_data);
     76        int rv = 0;
     77        if (_data != null) {
     78            for (int i = 0; i < 4; i++)
     79                rv ^= (_data[i] << (i*8));
     80        }
     81        return rv;
    7682    }
    7783   
  • core/java/src/net/i2p/data/PublicKey.java

    r1ecf437 r7736545f  
    7373    }
    7474   
     75    /** the key has enough randomness in it, use the first 4 bytes for speed */
    7576    @Override
    7677    public int hashCode() {
    77         return DataHelper.hashCode(_data);
     78        int rv = 0;
     79        if (_data != null) {
     80            for (int i = 0; i < 4; i++)
     81                rv ^= (_data[i] << (i*8));
     82        }
     83        return rv;
    7884    }
    7985   
  • core/java/src/net/i2p/data/RouterAddress.java

    r1ecf437 r7736545f  
    131131    }
    132132   
     133    /** the style should be sufficient, for speed */
    133134    @Override
    134135    public int hashCode() {
    135         return getCost() + DataHelper.hashCode(getTransportStyle()) + DataHelper.hashCode(getExpiration())
    136                + DataHelper.hashCode(getOptions());
     136        return DataHelper.hashCode(getTransportStyle());
    137137    }
    138138   
  • core/java/src/net/i2p/data/RouterIdentity.java

    r1ecf437 r7736545f  
    102102    }
    103103   
     104    /** the public key has enough randomness in it to use it by itself for speed */
    104105    @Override
    105106    public int hashCode() {
    106         return DataHelper.hashCode(getCertificate()) + DataHelper.hashCode(getSigningPublicKey())
    107                + DataHelper.hashCode(getPublicKey());
     107        if (_publicKey == null)
     108            return 0;
     109        return _publicKey.hashCode();
    108110    }
    109111   
  • core/java/src/net/i2p/data/SessionKey.java

    r1ecf437 r7736545f  
    7777    }
    7878   
     79    /** the key has enough randomness in it, use the first 4 bytes for speed */
    7980    @Override
    8081    public int hashCode() {
    81         return DataHelper.hashCode(_data);
     82        int rv = 0;
     83        if (_data != null) {
     84            for (int i = 0; i < 4; i++)
     85                rv ^= (_data[i] << (i*8));
     86        }
     87        return rv;
    8288    }
    8389
  • core/java/src/net/i2p/data/Signature.java

    r1ecf437 r7736545f  
    6363    }
    6464   
     65    /** the sig has enough randomness in it, use the first 4 bytes for speed */
    6566    @Override
    6667    public int hashCode() {
    67         return DataHelper.hashCode(_data);
     68        int rv = 0;
     69        if (_data != null) {
     70            for (int i = 0; i < 4; i++)
     71                rv ^= (_data[i] << (i*8));
     72        }
     73        return rv;
    6874    }
    6975
  • core/java/src/net/i2p/data/SigningPrivateKey.java

    r1ecf437 r7736545f  
    6969    }
    7070   
     71    /** the key has enough randomness in it, use the first 4 bytes for speed */
    7172    @Override
    7273    public int hashCode() {
    73         return DataHelper.hashCode(_data);
     74        int rv = 0;
     75        if (_data != null) {
     76            for (int i = 0; i < 4; i++)
     77                rv ^= (_data[i] << (i*8));
     78        }
     79        return rv;
    7480    }
    7581
  • core/java/src/net/i2p/data/SigningPublicKey.java

    r1ecf437 r7736545f  
    6868    }
    6969
     70    /** the key has enough randomness in it, use the first 4 bytes for speed */
    7071    @Override
    7172    public int hashCode() {
    72         return DataHelper.hashCode(_data);
     73        int rv = 0;
     74        if (_data != null) {
     75            for (int i = 0; i < 4; i++)
     76                rv ^= (_data[i] << (i*8));
     77        }
     78        return rv;
    7379    }
    7480
Note: See TracChangeset for help on using the changeset viewer.