diff options
author | Mark Spruiell <mes@zeroc.com> | 2008-02-13 12:24:33 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2008-02-13 12:24:33 -0800 |
commit | 615d05ee5646405a8c4d13a35ff6354a89db85c0 (patch) | |
tree | e0590cb71c39241b80d354b9c85507d2e1ed391c /java/src | |
parent | bug fix in Reference::hash() (diff) | |
download | ice-615d05ee5646405a8c4d13a35ff6354a89db85c0.tar.bz2 ice-615d05ee5646405a8c4d13a35ff6354a89db85c0.tar.xz ice-615d05ee5646405a8c4d13a35ff6354a89db85c0.zip |
cleaning up hashCode() for Reference, RoutableReference
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/IceInternal/Reference.java | 20 | ||||
-rw-r--r-- | java/src/IceInternal/RoutableReference.java | 13 |
2 files changed, 8 insertions, 25 deletions
diff --git a/java/src/IceInternal/Reference.java b/java/src/IceInternal/Reference.java index 26253b67daf..a05becb3c56 100644 --- a/java/src/IceInternal/Reference.java +++ b/java/src/IceInternal/Reference.java @@ -195,25 +195,11 @@ public abstract class Reference implements Cloneable int h = _mode; - int sz = _identity.name.length(); - for(int i = 0; i < sz; i++) - { - h = 5 * h + (int)_identity.name.charAt(i); - } - - sz = _identity.category.length(); - for(int i = 0; i < sz; i++) - { - h = 5 * h + (int)_identity.category.charAt(i); - } + h = 5 * h + _identity.hashCode(); - h = 5 * h + _context.entrySet().hashCode(); + h = 5 * h + _context.hashCode(); - sz = _facet.length(); - for(int i = 0; i < sz; i++) - { - h = 5 * h + (int)_facet.charAt(i); - } + h = 5 * h + _facet.hashCode(); h = 5 * h + (_secure ? 1 : 0); diff --git a/java/src/IceInternal/RoutableReference.java b/java/src/IceInternal/RoutableReference.java index 6bf1640750e..0b89530575f 100644 --- a/java/src/IceInternal/RoutableReference.java +++ b/java/src/IceInternal/RoutableReference.java @@ -339,15 +339,12 @@ public class RoutableReference extends Reference public synchronized int hashCode() { - if(_hashInitialized) + if(!_hashInitialized) { - return _hashValue; - } - super.hashCode(); - int sz = _adapterId.length(); // Add hash of adapter ID to base hash. - for(int i = 0; i < sz; i++) - { - _hashValue = 5 * _hashValue + (int)_adapterId.charAt(i); + super.hashCode(); // Initializes _hashValue. + + // Add hash of adapter ID to base hash. + _hashValue = 5 * _hashValue + _adapterId.hashCode(); } return _hashValue; } |