diff options
author | Gianmarco <gim.marcello@gmail.com> | 2024-03-28 10:54:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-28 10:54:29 +0100 |
commit | afc30a3b936f35bdbfdc59b4e3d44f25a1273525 (patch) | |
tree | 2145945f6a70a0217edeeb1315e6fcc460bb195f /lib/pure/collections/hashcommon.nim | |
parent | c934d5986d241c2a34c89ae3c16047299fd3a86b (diff) | |
download | Nim-afc30a3b936f35bdbfdc59b4e3d44f25a1273525.tar.gz |
Fix compile time errors when using tables on 8/16-bits systems. (#23450)
Refer to the discussion in #23439.
Diffstat (limited to 'lib/pure/collections/hashcommon.nim')
-rw-r--r-- | lib/pure/collections/hashcommon.nim | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/pure/collections/hashcommon.nim b/lib/pure/collections/hashcommon.nim index 8fd4c6e08..17785c8c7 100644 --- a/lib/pure/collections/hashcommon.nim +++ b/lib/pure/collections/hashcommon.nim @@ -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 |