File tree Expand file tree Collapse file tree 1 file changed +20
-23
lines changed Expand file tree Collapse file tree 1 file changed +20
-23
lines changed Original file line number Diff line number Diff line change @@ -17,36 +17,34 @@ unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector<unsigned char
17
17
{
18
18
// The following is MurmurHash3 (x86_32), see http://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp
19
19
uint32_t h1 = nHashSeed;
20
- if (vDataToHash.size () > 0 )
21
- {
22
- const uint32_t c1 = 0xcc9e2d51 ;
23
- const uint32_t c2 = 0x1b873593 ;
20
+ const uint32_t c1 = 0xcc9e2d51 ;
21
+ const uint32_t c2 = 0x1b873593 ;
24
22
25
- const int nblocks = vDataToHash.size () / 4 ;
23
+ const int nblocks = vDataToHash.size () / 4 ;
26
24
27
- // ----------
28
- // body
29
- const uint8_t * blocks = & vDataToHash[ 0 ] + nblocks * 4 ;
25
+ // ----------
26
+ // body
27
+ const uint8_t * blocks = vDataToHash. data () ;
30
28
31
- for (int i = -nblocks ; i; i++ ) {
32
- uint32_t k1 = ReadLE32 (blocks + i*4 );
29
+ for (int i = 0 ; i < nblocks; ++i ) {
30
+ uint32_t k1 = ReadLE32 (blocks + i*4 );
33
31
34
- k1 *= c1;
35
- k1 = ROTL32 (k1, 15 );
36
- k1 *= c2;
32
+ k1 *= c1;
33
+ k1 = ROTL32 (k1, 15 );
34
+ k1 *= c2;
37
35
38
- h1 ^= k1;
39
- h1 = ROTL32 (h1, 13 );
40
- h1 = h1 * 5 + 0xe6546b64 ;
41
- }
36
+ h1 ^= k1;
37
+ h1 = ROTL32 (h1, 13 );
38
+ h1 = h1 * 5 + 0xe6546b64 ;
39
+ }
42
40
43
- // ----------
44
- // tail
45
- const uint8_t * tail = ( const uint8_t *)(&vDataToHash[ 0 ] + nblocks * 4 ) ;
41
+ // ----------
42
+ // tail
43
+ const uint8_t * tail = vDataToHash. data () + nblocks * 4 ;
46
44
47
- uint32_t k1 = 0 ;
45
+ uint32_t k1 = 0 ;
48
46
49
- switch (vDataToHash.size () & 3 ) {
47
+ switch (vDataToHash.size () & 3 ) {
50
48
case 3 :
51
49
k1 ^= tail[2 ] << 16 ;
52
50
case 2 :
@@ -57,7 +55,6 @@ unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector<unsigned char
57
55
k1 = ROTL32 (k1, 15 );
58
56
k1 *= c2;
59
57
h1 ^= k1;
60
- }
61
58
}
62
59
63
60
// ----------
You can’t perform that action at this time.
0 commit comments