From 52c1d019d63d2fffadc8f3f159d654187ac61ece Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 8 Sep 2011 05:43:32 +0000 Subject: Refinement of murmurhash implementation. Integrates recent speed improvements to algorithm. Contributed by Ruediger Keller, no review. --- src/compiler/scala/tools/nsc/util/BitSet.scala | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/scala/tools/nsc/util/BitSet.scala b/src/compiler/scala/tools/nsc/util/BitSet.scala index a8d54c2c84..de0c6fd62a 100644 --- a/src/compiler/scala/tools/nsc/util/BitSet.scala +++ b/src/compiler/scala/tools/nsc/util/BitSet.scala @@ -72,20 +72,15 @@ abstract class BitSet { } override def hashCode: Int = { - import scala.util.MurmurHash._ - var h = startHash(hashSeed) - var c = startMagicA - var k = startMagicB - for (idx <- 0 until nwords) { - val w = word(idx) - h = extendHash(h, (w>>>32).toInt, c, k) - c = nextMagicA(c) - k = nextMagicB(k) - h = extendHash(h, w.toInt, c, k) - c = nextMagicA(c) - k = nextMagicB(k) + import scala.util.MurmurHash3._ + var h = hashSeed + var i = 0; while(i < nwords) { + val w = word(i) + h = mix(h, (w >>> 32).toInt) + h = mix(h, w.toInt) + i += 1 } - finalizeHash(h) + finalizeHash(h, nwords) } def addString(sb: StringBuilder, start: String, sep: String, end: String) { -- cgit v1.2.3