From 442fa5b46a2f3fd8c70e68dce870ac961198cc63 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Mon, 19 Mar 2018 17:18:02 +0100 Subject: [PATCH] Fix hashing scalar types --- source/tanya/hash/lookup.d | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/tanya/hash/lookup.d b/source/tanya/hash/lookup.d index 643601e..817670b 100644 --- a/source/tanya/hash/lookup.d +++ b/source/tanya/hash/lookup.d @@ -40,7 +40,7 @@ private struct FNV { static if (isScalarType!T) { - (() @trusted => add(cast(const ubyte[]) (&key)[0 .. T.sizeof]))(); + (() @trusted => add((cast(const ubyte*) &key)[0 .. T.sizeof]))(); } else static if (isArray!T && isScalarType!(ElementType!T)) { @@ -162,12 +162,14 @@ static if (size_t.sizeof == 4) @nogc nothrow pure @safe unittest { assert(hash('a') == 0xe40c292cU); assert(hash(HashRange()) == 0x6222e842U); + assert(hash(ToHashRange()) == 1268118805U); } static if (size_t.sizeof == 8) @nogc nothrow pure @safe unittest { assert(hash('a') == 0xaf63dc4c8601ec8cUL); assert(hash(HashRange()) == 0x08985907b541d342UL); + assert(hash(ToHashRange()) == 12161962213042174405UL); } /*