Fix hashing scalar types

This commit is contained in:
Eugen Wissner 2018-03-19 17:18:02 +01:00
parent 0d6d8f6a91
commit 442fa5b46a

View File

@ -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);
}
/*