Fix compile time errors when using tables on 8/16-bits systems. (#23450)

Refer to the discussion in #23439.
This commit is contained in:
Gianmarco
2024-03-28 10:54:29 +01:00
committed by GitHub
parent c934d5986d
commit afc30a3b93

View File

@@ -58,7 +58,10 @@ proc rawGetKnownHC[X, A](t: X, key: A, hc: Hash): int {.inline.} =
template genHashImpl(key, hc: typed) =
hc = hash(key)
if hc == 0: # This almost never taken branch should be very predictable.
hc = 314159265 # Value doesn't matter; Any non-zero favorite is fine.
when sizeof(int) < 4:
hc = 31415 # Value doesn't matter; Any non-zero favorite is fine <= 16-bit.
else:
hc = 314159265 # Value doesn't matter; Any non-zero favorite is fine.
template genHash(key: typed): Hash =
var res: Hash