From a29be6f1b0d73aa6b934618f57ca4ec52aef0053 Mon Sep 17 00:00:00 2001 From: Jarl Holta Date: Fri, 6 Dec 2024 12:28:52 +0100 Subject: [PATCH] 64bit hash performance boost 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 --- Source/simba.container_dict.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/simba.container_dict.pas b/Source/simba.container_dict.pas index af5ba42a7..fcee61e2e 100644 --- a/Source/simba.container_dict.pas +++ b/Source/simba.container_dict.pas @@ -172,7 +172,7 @@ class function TDictionary.HashInt32(constref k: Int32): UInt32; class function TDictionary.HashInt64(constref k: Int64): UInt32; begin - Result := UInt32(k); + Result := (UInt32(k) * 31) xor UInt32(k shr 32); end; // FNV