Skip to content

Commit

Permalink
use simplest hash func for small integer types
Browse files Browse the repository at this point in the history
  • Loading branch information
ikod committed Aug 24, 2020
1 parent 89c9b9d commit db5718d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source/ikod/containers/hash.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ if ( UseToHashMethod!T )
public hash_t hash_function(T)(in T v) @nogc @trusted
if ( !UseToHashMethod!T )
{
static if ( isNumeric!T ) {
static if (is(T==int) || is(T==uint) || is(T==byte) || is(T==ubyte))
{
return v;
}
else static if ( isNumeric!T ) {
enum m = 0x5bd1e995;
hash_t h = cast(hash_t)v;
h ^= h >> 13;
Expand Down

0 comments on commit db5718d

Please sign in to comment.