summary refs log tree commit diff stats
path: root/lib/pure/hashes.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2017-06-09 13:39:42 +0200
committerAraq <rumpf_a@web.de>2017-06-09 13:39:42 +0200
commit72115c2b0996cd7b33ed0f161d4d1a997caaf1db (patch)
tree6a162590576373a4e0244b0cdfbd822b5e90f36d /lib/pure/hashes.nim
parent280941aca675d91abbd348aa45848c6e0585c879 (diff)
downloadNim-72115c2b0996cd7b33ed0f161d4d1a997caaf1db.tar.gz
fixes #5969
Diffstat (limited to 'lib/pure/hashes.nim')
-rw-r--r--lib/pure/hashes.nim11
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 =