Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit57d6ce4

Browse files
committed
Do not use rangeHash when rangeDiff is 0
1 parent03b79e9 commit57d6ce4

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

‎src/library/scala/util/hashing/MurmurHash3.scala‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private[hashing] class MurmurHash3 {
136136
while (it.hasNext) {
137137
h= mix(h, prev)
138138
valhash= it.next().##
139-
if(rangeDiff!= hash- prev) {
139+
if(rangeDiff!= hash- prev|| rangeDiff==0) {
140140
h= mix(h, hash)
141141
i+=1
142142
while (it.hasNext) {
@@ -173,7 +173,7 @@ private[hashing] class MurmurHash3 {
173173
while (i< l) {
174174
h= mix(h, prev)
175175
valhash= a(i).##
176-
if(rangeDiff!= hash- prev) {
176+
if(rangeDiff!= hash- prev|| rangeDiff==0) {
177177
h= mix(h, hash)
178178
i+=1
179179
while (i< l) {
@@ -252,7 +252,7 @@ private[hashing] class MurmurHash3 {
252252
while (i< l) {
253253
h= mix(h, prev)
254254
valhash= a(i).##
255-
if(rangeDiff!= hash- prev) {
255+
if(rangeDiff!= hash- prev|| rangeDiff==0) {
256256
h= mix(h, hash)
257257
i+=1
258258
while (i< l) {
@@ -290,7 +290,7 @@ private[hashing] class MurmurHash3 {
290290
rangeState=1
291291
case1=>
292292
rangeDiff= hash- prev
293-
rangeState=2
293+
rangeState=if (rangeDiff==0)3else2
294294
case2=>
295295
if(rangeDiff!= hash- prev) rangeState=3
296296
case _=>

‎test/junit/scala/util/hashing/MurmurHash3Test.scala‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,13 @@ class MurmurHash3Test {
5656
assertEquals(r5, r6)
5757
assertEquals(r5.hashCode, r6.hashCode)
5858
}
59+
60+
@Test
61+
deftestEqualArray():Unit= {
62+
valz1= (1 to2).map(_=>0).toArray
63+
valz2= (1 to5).map(_=>0).toArray
64+
check(z1.hashCode, z1)
65+
check(z2.hashCode, z2)
66+
assertNotEquals(z1.hashCode, z2.hashCode)
67+
}
5968
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp