File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -91,11 +91,17 @@ proc hashData*(data: pointer, size: int): Hash =
9191
9292proc hashBiggestIntVM (x: BiggestInt ): Hash = discard # in vmops
9393
94+ proc hash * (x: string ): Hash
95+
9496proc hashBiggestInt * (x: BiggestInt ): Hash {.inline .} =
9597 # # for internal use; user code should prefer `hash` overloads
9698 when nimvm : hashBiggestIntVM (x)
97- else : hashData (cast [pointer ](unsafeAddr x), type (x).sizeof)
98-
99+ else :
100+ when defined (js):
101+ # could use BigInt, see https://github.com/nim-lang/RFCs/issues/187
102+ hash ($ x)
103+ else :
104+ hashData (cast [pointer ](unsafeAddr x), type (x).sizeof)
99105
100106proc hash * [T: SomeNumber | Ordinal | char ](x: T): Hash {.inline .} =
101107 # # Efficient hashing of numbers, ordinals (eg enum), char.
You can’t perform that action at this time.
0 commit comments