Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #991 from IgorStepanov/remove-mixHash
Browse files Browse the repository at this point in the history
remove mixHash
  • Loading branch information
MartinNowak committed Oct 14, 2014
2 parents 92c2e54 + 6da8b3b commit 099cce4
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/core/internal/hash.d
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ size_t hashOf(T)(auto ref T val, size_t seed = 0) if (!is(T == enum) && (is(T ==
{
static if (is(typeof(val.toHash()) == size_t)) //CTFE depends on toHash()
{
return mixHash(val.toHash(), seed);
return hashOf(val.toHash(), seed);
}
else
{
Expand Down Expand Up @@ -148,13 +148,13 @@ size_t hashOf(T)(auto ref T val, size_t seed = 0) if (!is(T == enum) && is(T ==
//class or interface hash. CTFE depends on toHash
size_t hashOf(T)(auto ref T val, size_t seed = 0) if (!is(T == enum) && is(T == interface) || is(T == class))
{
return mixHash(val ? (cast(Object)val).toHash() : 0, seed);
return hashOf(val ? (cast(Object)val).toHash() : 0, seed);
}

//associative array hash. CTFE depends on base types
size_t hashOf(T)(auto ref T aa, size_t seed = 0) if (!is(T == enum) && __traits(isAssociativeArray, T))
{
if (!aa.length) return mixHash(0, seed);
if (!aa.length) return hashOf(0, seed);
size_t h = 0;

// The computed hash is independent of the foreach traversal order.
Expand All @@ -165,7 +165,7 @@ size_t hashOf(T)(auto ref T aa, size_t seed = 0) if (!is(T == enum) && __traits(
hpair[1] = val.hashOf();
h ^= hpair.hashOf();
}
return mixHash(h, seed);
return h.hashOf(seed);
}

unittest
Expand Down Expand Up @@ -494,14 +494,6 @@ size_t bytesHash(const(void)* buf, size_t len, size_t seed = 0)
return h1;
}


@trusted pure nothrow
size_t mixHash(size_t hash, size_t seed)
{
auto h = hash.toUbyte();
return bytesHash(h.ptr, h.length, seed);
}

// Check that bytesHash works with CTFE
unittest
{
Expand Down

0 comments on commit 099cce4

Please sign in to comment.