|
33 | 33 | _memhash(siz, ptr, seed) =
|
34 | 34 | ccall(Base.memhash, UInt, (Ptr{UInt8}, Csize_t, UInt32), ptr, siz, seed % UInt32)
|
35 | 35 |
|
36 |
| -# Optimized code for hashing empty string |
37 |
| -_hash(seed) = last(mmhash128_a(seed%UInt32)) + seed |
38 |
| -# Optimized for hashing a UTF-8 compatible aligned string |
39 |
| -_hash(str, seed) = last(mmhash128(str, seed%UInt32)) + seed |
40 |
| -# For hashing generic abstract strings as if UTF-8 encoded |
41 | 36 | @static if sizeof(Int) == 8
|
| 37 | + # Optimized code for hashing empty string |
| 38 | + _hash(seed) = last(mmhash128_a(seed%UInt32)) + seed |
| 39 | + # Optimized for hashing a UTF-8 compatible aligned string |
| 40 | + _hash(str, seed) = last(mmhash128(str, seed%UInt32)) + seed |
| 41 | + # For hashing generic abstract strings as if UTF-8 encoded |
42 | 42 | _hash_abs(str, seed) = last(mmhash128_c(str, seed%UInt32)) + seed
|
43 | 43 | else
|
44 |
| - function _hash_abs(str, seed) |
45 |
| - s = string(str) |
46 |
| - @preserve s last(mmhash128_a(sizeof(s), pointer(s), seed%UInt32)) + seed |
47 |
| - end |
| 44 | + _hash(seed) = MurmurHash3.fmix(seed%UInt32) + seed |
| 45 | + # Optimized for hashing a UTF-8 compatible aligned string |
| 46 | + _hash(s, seed) = @preserve s mmhash32(sizeof(s), pointer(s), seed%UInt32) + seed |
| 47 | + _hash_abs(s, seed) = _hash(string(s), seed) |
48 | 48 | end
|
49 | 49 |
|
50 | 50 | hash(str::Union{S,SubString{S}}, seed::UInt) where {S<:Str} =
|
|
0 commit comments