14
14
15
15
package com .rabbitmq .stream .impl ;
16
16
17
+ import edu .umd .cs .findbugs .annotations .SuppressFBWarnings ;
17
18
import java .nio .charset .StandardCharsets ;
18
19
import java .util .function .ToIntFunction ;
19
20
@@ -25,6 +26,7 @@ private HashUtils() {}
25
26
26
27
// from
27
28
// https://github.com/apache/commons-codec/blob/rel/commons-codec-1.15/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
29
+ // hash32x86 method
28
30
static class Murmur3 implements ToIntFunction <String > {
29
31
30
32
private static final int DEFAULT_SEED = 104729 ;
@@ -37,10 +39,10 @@ static class Murmur3 implements ToIntFunction<String> {
37
39
private static final int N_32 = 0xe6546b64 ;
38
40
39
41
private static int getLittleEndianInt (final byte [] data , final int index ) {
40
- return (( data [index ] & 0xff ))
41
- | (( data [index + 1 ] & 0xff ) << 8 )
42
- | (( data [index + 2 ] & 0xff ) << 16 )
43
- | (( data [index + 3 ] & 0xff ) << 24 ) ;
42
+ return data [index ] & 0xff
43
+ | (data [index + 1 ] & 0xff ) << 8
44
+ | (data [index + 2 ] & 0xff ) << 16
45
+ | (data [index + 3 ] & 0xff ) << 24 ;
44
46
}
45
47
46
48
private static int mix32 (int k , int hash ) {
@@ -70,6 +72,7 @@ private static int fmix32(int hash) {
70
72
this .seed = seed ;
71
73
}
72
74
75
+ @ SuppressFBWarnings ({"SF_SWITCH_FALLTHROUGH" , "SF_SWITCH_NO_DEFAULT" })
73
76
@ Override
74
77
public int applyAsInt (String value ) {
75
78
byte [] data = value .getBytes (StandardCharsets .UTF_8 );
@@ -94,7 +97,7 @@ public int applyAsInt(String value) {
94
97
case 2 :
95
98
k1 ^= (data [index + 1 ] & 0xff ) << 8 ;
96
99
case 1 :
97
- k1 ^= ( data [index ] & 0xff ) ;
100
+ k1 ^= data [index ] & 0xff ;
98
101
99
102
// mix functions
100
103
k1 *= C1_32 ;
0 commit comments