From 8a8a88f781b32bed29c36528686a522ab954afae Mon Sep 17 00:00:00 2001 From: ScottPJones Date: Wed, 12 May 2021 22:31:22 -0400 Subject: [PATCH] Update version and requirement for MurmurHash3 --- Project.toml | 4 ++-- src/ShortStrings.jl | 6 +++++- test/runtests.jl | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index 5e5abdb..f11816f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ShortStrings" uuid = "63221d1c-8677-4ff0-9126-0ff0817b4975" authors = ["Dai ZJ ", "ScottPJones ", "Lyndon White "] -version = "0.3.8" +version = "0.3.9" [deps] BitIntegers = "c3b6d118-76ef-56ca-8cc7-ebb389d030a1" @@ -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" diff --git a/src/ShortStrings.jl b/src/ShortStrings.jl index 076cb7e..6666308 100644 --- a/src/ShortStrings.jl +++ b/src/ShortStrings.jl @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index bdbe757..569ac7b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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!!!")