diff options
author | Paul Phillips <paulp@improving.org> | 2010-05-21 17:07:50 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-05-21 17:07:50 +0000 |
commit | 712ebe2943640b34ff40b40a363bd72594e62cb5 (patch) | |
tree | 33e109835d03eb5710efcec14c0cb14aec79bf8e /src/library | |
parent | 4382c7dd6e1b079919587639b6979ad55a783db5 (diff) | |
download | scala-712ebe2943640b34ff40b40a363bd72594e62cb5.tar.gz scala-712ebe2943640b34ff40b40a363bd72594e62cb5.tar.bz2 scala-712ebe2943640b34ff40b40a363bd72594e62cb5.zip |
Altered a bunch of places which call hashCode t...
Altered a bunch of places which call hashCode to call ## instead. No
review.
Diffstat (limited to 'src/library')
22 files changed, 27 insertions, 24 deletions
diff --git a/src/library/scala/Enumeration.scala b/src/library/scala/Enumeration.scala index ab944b20a8..5d1a0997ed 100644 --- a/src/library/scala/Enumeration.scala +++ b/src/library/scala/Enumeration.scala @@ -230,7 +230,7 @@ abstract class Enumeration(initial: Int, names: String*) { thisenum => case that: thisenum.Value => compare(that) == 0 case _ => false } - override def hashCode: Int = id.hashCode + override def hashCode: Int = id.## /** this enumeration value as an <code>Int</code> bit mask. * @throws IllegalArgumentException if <code>id</code> is greater than 31 diff --git a/src/library/scala/Proxy.scala b/src/library/scala/Proxy.scala index d37b8f5e5d..feac5904a5 100644 --- a/src/library/scala/Proxy.scala +++ b/src/library/scala/Proxy.scala @@ -21,7 +21,7 @@ package scala */ trait Proxy { def self: Any - override def hashCode: Int = self.hashCode + override def hashCode: Int = self.## override def equals(that: Any): Boolean = if(that == null) false else that equals self diff --git a/src/library/scala/collection/MapLike.scala b/src/library/scala/collection/MapLike.scala index 9edc2904e1..fdaee64fd5 100644 --- a/src/library/scala/collection/MapLike.scala +++ b/src/library/scala/collection/MapLike.scala @@ -329,7 +329,7 @@ self => override /*PartialFunction*/ def toString = super[IterableLike].toString - override def hashCode() = this map (_.hashCode) sum + override def hashCode() = this map (_.##) sum /** Compares two maps structurally; i.e. checks if all mappings * contained in this map are also contained in the other map, diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index 5f75169f3c..8770de9c36 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -857,7 +857,7 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] { self => /** Hashcodes for $Coll produce a value from the hashcodes of all the * elements of the $coll. */ - override def hashCode() = (Seq.hashSeed /: this)(_ * 41 + _.hashCode) + override def hashCode() = (Seq.hashSeed /: this)(_ * 41 + _.##) override def equals(that: Any): Boolean = that match { case that: Seq[_] => (that canEqual this) && (this sameElements that) diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala index 71de59b861..01ef597d24 100644 --- a/src/library/scala/collection/immutable/HashMap.scala +++ b/src/library/scala/collection/immutable/HashMap.scala @@ -58,7 +58,7 @@ class HashMap[A, +B] extends Map[A,B] with MapLike[A, B, HashMap[A, B]] { def - (key: A): HashMap[A, B] = removed0(key, computeHash(key), 0) - protected def elemHashCode(key: A) = if (key == null) 0 else key.hashCode() + protected def elemHashCode(key: A) = if (key == null) 0 else key.## protected final def improve(hcode: Int) = { var h: Int = hcode + ~(hcode << 9) diff --git a/src/library/scala/collection/immutable/HashSet.scala b/src/library/scala/collection/immutable/HashSet.scala index 8f77c2e916..08e64d6709 100644 --- a/src/library/scala/collection/immutable/HashSet.scala +++ b/src/library/scala/collection/immutable/HashSet.scala @@ -55,7 +55,7 @@ class HashSet[A] extends Set[A] def - (e: A): HashSet[A] = removed0(e, computeHash(e), 0) - protected def elemHashCode(key: A) = if (key == null) 0 else key.hashCode() + protected def elemHashCode(key: A) = if (key == null) 0 else key.## protected final def improve(hcode: Int) = { var h: Int = hcode + ~(hcode << 9) diff --git a/src/library/scala/collection/immutable/TreeHashMap.scala b/src/library/scala/collection/immutable/TreeHashMap.scala index 1a2d34cc38..a7de5bf8d1 100644 --- a/src/library/scala/collection/immutable/TreeHashMap.scala +++ b/src/library/scala/collection/immutable/TreeHashMap.scala @@ -54,7 +54,7 @@ class TreeHashMap[Key, +Value] private (private val underlying : IntMap[AssocMap def empty[V] = TreeHashMap.empty[Key, V] private def hash(key : Key) = { - var h = key.hashCode; + var h = key.## h ^= ((h >>> 20) ^ (h >>> 12)); h ^ (h >>> 7) ^ (h >>> 4); } diff --git a/src/library/scala/collection/mutable/HashTable.scala b/src/library/scala/collection/mutable/HashTable.scala index be266be543..b924a38dde 100644 --- a/src/library/scala/collection/mutable/HashTable.scala +++ b/src/library/scala/collection/mutable/HashTable.scala @@ -228,7 +228,7 @@ trait HashTable[A] { protected def elemEquals(key1: A, key2: A): Boolean = (key1 == key2) - protected def elemHashCode(key: A) = if (key == null) 0 else key.hashCode() + protected def elemHashCode(key: A) = if (key == null) 0 else key.## protected final def improve(hcode: Int) = { var h: Int = hcode + ~(hcode << 9) diff --git a/src/library/scala/collection/mutable/LinkedHashSet.scala b/src/library/scala/collection/mutable/LinkedHashSet.scala index 71f38182db..922ff25276 100644 --- a/src/library/scala/collection/mutable/LinkedHashSet.scala +++ b/src/library/scala/collection/mutable/LinkedHashSet.scala @@ -68,7 +68,7 @@ class LinkedHashSet[A] extends Set[A] clearTable() } - override def iterator = ordered.iterator + override def iterator: Iterator[A] = ordered.iterator override def foreach[U](f: A => U) = ordered foreach f diff --git a/src/library/scala/collection/mutable/OpenHashMap.scala b/src/library/scala/collection/mutable/OpenHashMap.scala index 9c1560ad24..b10b88049e 100644 --- a/src/library/scala/collection/mutable/OpenHashMap.scala +++ b/src/library/scala/collection/mutable/OpenHashMap.scala @@ -91,7 +91,7 @@ extends Map[Key, Value] /** Returns a mangled hash code of the provided key. */ protected def hashOf(key : Key) = { - var h = key.hashCode; + var h = key.## h ^= ((h >>> 20) ^ (h >>> 12)); h ^ (h >>> 7) ^ (h >>> 4); } diff --git a/src/library/scala/math/BigDecimal.scala b/src/library/scala/math/BigDecimal.scala index 7312c0d2c0..e1d44862e4 100644 --- a/src/library/scala/math/BigDecimal.scala +++ b/src/library/scala/math/BigDecimal.scala @@ -173,7 +173,7 @@ extends ScalaNumber with ScalaNumericConversions */ override def hashCode(): Int = if (isWhole) unifiedPrimitiveHashcode - else doubleValue.hashCode() + else doubleValue.## /** Compares this BigDecimal with the specified value for equality. */ diff --git a/src/library/scala/math/BigInt.scala b/src/library/scala/math/BigInt.scala index aef48806c2..79b377bc6c 100644 --- a/src/library/scala/math/BigInt.scala +++ b/src/library/scala/math/BigInt.scala @@ -116,7 +116,7 @@ class BigInt(val bigInteger: BigInteger) extends ScalaNumber with ScalaNumericCo /** Returns the hash code for this BigInt. */ override def hashCode(): Int = if (this >= BigInt.MinLong && this <= BigInt.MaxLong) unifiedPrimitiveHashcode - else bigInteger.hashCode + else bigInteger.## /** Compares this BigInt with the specified value for equality. */ diff --git a/src/library/scala/math/ScalaNumericConversions.scala b/src/library/scala/math/ScalaNumericConversions.scala index 2e754c2584..34698ea39f 100644 --- a/src/library/scala/math/ScalaNumericConversions.scala +++ b/src/library/scala/math/ScalaNumericConversions.scala @@ -30,7 +30,7 @@ trait ScalaNumericConversions extends ScalaNumber { protected def unifiedPrimitiveHashcode() = { val lv = toLong if (lv >= Int.MinValue && lv <= Int.MaxValue) lv.toInt - else lv.hashCode + else lv.## } /** Should only be called after all known non-primitive diff --git a/src/library/scala/reflect/ClassManifest.scala b/src/library/scala/reflect/ClassManifest.scala index 777908d142..0337ed6aed 100644 --- a/src/library/scala/reflect/ClassManifest.scala +++ b/src/library/scala/reflect/ClassManifest.scala @@ -85,7 +85,7 @@ trait ClassManifest[T] extends OptManifest[T] with Equals { case m: ClassManifest[_] if m canEqual this => this.erasure == m.erasure case _ => false } - override def hashCode = this.erasure.hashCode + override def hashCode = this.erasure.## protected def arrayClass[T](tp: Predef.Class[_]): Predef.Class[Array[T]] = java.lang.reflect.Array.newInstance(tp, 0).getClass.asInstanceOf[Predef.Class[Array[T]]] diff --git a/src/library/scala/reflect/Manifest.scala b/src/library/scala/reflect/Manifest.scala index 1009ca8c85..6faa99c4c8 100644 --- a/src/library/scala/reflect/Manifest.scala +++ b/src/library/scala/reflect/Manifest.scala @@ -40,7 +40,7 @@ trait Manifest[T] extends ClassManifest[T] with Equals { case m: Manifest[_] if m canEqual this => (this <:< m) && (m <:< this) case _ => false } - override def hashCode = this.erasure.hashCode + override def hashCode = this.erasure.## } @serializable diff --git a/src/library/scala/reflect/generic/Constants.scala b/src/library/scala/reflect/generic/Constants.scala index d9faac653f..bf963a1aae 100755 --- a/src/library/scala/reflect/generic/Constants.scala +++ b/src/library/scala/reflect/generic/Constants.scala @@ -230,6 +230,6 @@ trait Constants { self: Universe => def symbolValue: Symbol = value.asInstanceOf[Symbol] override def hashCode: Int = - if (value == null) 0 else value.hashCode() * 41 + 17 + if (value == null) 0 else value.## * 41 + 17 } } diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index bc28e48163..26dc0830e5 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -154,7 +154,7 @@ object ScalaRunTime { var i = 0 while (i < arr) { val elem = x.productElement(i) - code = code * 41 + (if (elem == null) 0 else elem.hashCode()) + code = code * 41 + (if (elem == null) 0 else elem.##) i += 1 } code @@ -175,6 +175,9 @@ object ScalaRunTime { } // hashcode ----------------------------------------------------------- + // + // Note that these are the implementations called by ##, so they + // must not call ## themselves. @inline def hash(x: Any): Int = if (x.isInstanceOf[java.lang.Number]) BoxesRunTime.hashFromNumber(x.asInstanceOf[java.lang.Number]) diff --git a/src/library/scala/util/JenkinsHash.scala b/src/library/scala/util/JenkinsHash.scala index fcd263f5c9..83df5ad834 100644 --- a/src/library/scala/util/JenkinsHash.scala +++ b/src/library/scala/util/JenkinsHash.scala @@ -124,7 +124,7 @@ object JenkinsHash { */ def hashSeq(xs: Seq[Any]): Int = { val (values, refs) = partitionValuesAndRefs(xs) - val refsSum = refs map (x => if (x == null) 0 else x.hashCode) sum + val refsSum = refs map (x => if (x == null) 0 else x.##) sum hashAnyValSeq(values) + refsSum } diff --git a/src/library/scala/xml/Equality.scala b/src/library/scala/xml/Equality.scala index d09ae10b2d..210029b3bd 100644 --- a/src/library/scala/xml/Equality.scala +++ b/src/library/scala/xml/Equality.scala @@ -74,7 +74,7 @@ trait Equality extends scala.Equals { def strict_==(other: Equality): Boolean def strict_!=(other: Equality) = !strict_==(other) - private def hashOf(x: Any) = if (x == null) 1 else x.hashCode() + private def hashOf(x: Any) = if (x == null) 1 else x.## /** We insist we're only equal to other xml.Equality implementors, * which heads off a lot of inconsistency up front. diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index 9880e7bd4b..65d7179fa2 100644 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -261,14 +261,14 @@ object Utility extends AnyRef with parsing.TokenTests * @param children */ def hashCode(pre: String, label: String, attribHashCode: Int, scpeHash: Int, children: Seq[Node]) = ( - ( if(pre ne null) {41 * pre.hashCode() % 7} else {0}) - + label.hashCode() * 53 + ( if(pre ne null) {41 * pre.## % 7} else {0}) + + label.## * 53 + attribHashCode * 7 + scpeHash * 31 + { var c = 0 val i = children.iterator - while(i.hasNext) c = c * 41 + i.next.hashCode + while(i.hasNext) c = c * 41 + i.next.## c } ) diff --git a/src/library/scala/xml/factory/LoggedNodeFactory.scala b/src/library/scala/xml/factory/LoggedNodeFactory.scala index 8c965128ee..2159f8c106 100644 --- a/src/library/scala/xml/factory/LoggedNodeFactory.scala +++ b/src/library/scala/xml/factory/LoggedNodeFactory.scala @@ -58,7 +58,7 @@ with scala.util.logging.Logged { if (logNode) log("[makeNode for "+label+"]"); - val hash = Utility.hashCode(pre, label, attrSeq.hashCode(), scope.hashCode(), children) + val hash = Utility.hashCode(pre, label, attrSeq.##, scope.##, children) /* if(logCompressLevel >= FULL) { diff --git a/src/library/scala/xml/factory/NodeFactory.scala b/src/library/scala/xml/factory/NodeFactory.scala index 7613041f04..4178a38cd9 100644 --- a/src/library/scala/xml/factory/NodeFactory.scala +++ b/src/library/scala/xml/factory/NodeFactory.scala @@ -40,7 +40,7 @@ trait NodeFactory[A <: Node] eqElements(n.child, children) def makeNode(pre: String, name: String, attrSeq: MetaData, scope: NamespaceBinding, children: Seq[Node]): A = { - val hash = Utility.hashCode( pre, name, attrSeq.hashCode(), scope.hashCode(), children) + val hash = Utility.hashCode( pre, name, attrSeq.##, scope.##, children) def cons(old: List[A]) = construct(hash, old, pre, name, attrSeq, scope, children) (cache get hash) match { |