Skip to content

Commit

Permalink
Merge pull request #52 from JuliaString/spj/ver
Browse files Browse the repository at this point in the history
Update version and requirement for MurmurHash3
  • Loading branch information
ScottPJones authored May 13, 2021
2 parents 20c5d07 + 8a8a88f commit 85ae43f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ShortStrings"
uuid = "63221d1c-8677-4ff0-9126-0ff0817b4975"
authors = ["Dai ZJ <[email protected]>", "ScottPJones <[email protected]>", "Lyndon White <[email protected]>"]
version = "0.3.8"
version = "0.3.9"

[deps]
BitIntegers = "c3b6d118-76ef-56ca-8cc7-ebb389d030a1"
Expand All @@ -10,7 +10,7 @@ SortingAlgorithms = "a2af1166-a08f-5f64-846c-94a0d3cef48c"

[compat]
BitIntegers = "0.2"
MurmurHash3 = "1.1"
MurmurHash3 = "1.2"
SortingAlgorithms = "0.3"
julia = "1"

Expand Down
6 changes: 5 additions & 1 deletion src/ShortStrings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ export @ss_str, @ss3_str, @ss7_str, @ss15_str, @ss31_str, @ss63_str, @ss127_str,

include("base.jl")

using MurmurHash3: mmhash128_a
using MurmurHash3: mmhash128_a, mmhash32

function Base.hash(x::ShortString, h::UInt)
h += Base.memhash_seed
@static if UInt === UInt64
last(mmhash128_a(sizeof(x), bswap(x.size_content), h%UInt32)) + h
else
mmhash32(sizeof(x), bswap(x.size_content), h%UInt32) + h
end
end

end # module
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ ss = ShortString15(s)
@test s[1] == ss[1]

@test ss127"Be honest, do you actually need a string longer than this. Seriously. C'mon this is pretty long." === ShortString127("Be honest, do you actually need a string longer than this. Seriously. C'mon this is pretty long.")
@test ss63"Basically a failly long string really" === ShortString63("Basically a failly long string really")
@test ss63"Basically a fairly long string really" === ShortString63("Basically a fairly long string really")
@test ss31"A Longer String!!!" === ShortString31("A Longer String!!!")

@test ss15"Short String!!!" === ShortString15("Short String!!!")
Expand Down

0 comments on commit 85ae43f

Please sign in to comment.