diff options
author | Araq <rumpf_a@web.de> | 2017-06-09 13:39:42 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2017-06-09 13:39:42 +0200 |
commit | 72115c2b0996cd7b33ed0f161d4d1a997caaf1db (patch) | |
tree | 6a162590576373a4e0244b0cdfbd822b5e90f36d /lib/pure/hashes.nim | |
parent | 280941aca675d91abbd348aa45848c6e0585c879 (diff) | |
download | Nim-72115c2b0996cd7b33ed0f161d4d1a997caaf1db.tar.gz |
fixes #5969
Diffstat (limited to 'lib/pure/hashes.nim')
-rw-r--r-- | lib/pure/hashes.nim | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/pure/hashes.nim b/lib/pure/hashes.nim index e8c8776c6..b015ed311 100644 --- a/lib/pure/hashes.nim +++ b/lib/pure/hashes.nim @@ -139,9 +139,14 @@ proc hash*(x: cstring): Hash = ## efficient hashing of null-terminated strings var h: Hash = 0 var i = 0 - while x[i] != 0.char: - h = h !& ord(x[i]) - inc i + when defined(js): + while i < x.len: + h = h !& ord(x[i]) + inc i + else: + while x[i] != 0.char: + h = h !& ord(x[i]) + inc i result = !$h proc hash*(sBuf: string, sPos, ePos: int): Hash = |