Skip to content

Commit

Permalink
64bit hash performance boost
Browse files Browse the repository at this point in the history
We want to include the second part of the 64bit value - we also introduce a small prime to improve distribution.

Result is SymmetricDifference and Difference being 10-20x faster for large 64bit data
  • Loading branch information
slackydev committed Dec 6, 2024
1 parent 176da91 commit a29be6f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Source/simba.container_dict.pas
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class function TDictionary<K,V>.HashInt32(constref k: Int32): UInt32;

class function TDictionary<K,V>.HashInt64(constref k: Int64): UInt32;
begin
Result := UInt32(k);
Result := (UInt32(k) * 31) xor UInt32(k shr 32);
end;

// FNV
Expand Down

0 comments on commit a29be6f

Please sign in to comment.