This commit is contained in:
Araq 2017-06-09 13:39:42 +02:00
commit 72115c2b09

View file

@ -139,6 +139,11 @@ proc hash*(x: cstring): Hash =
## efficient hashing of null-terminated strings ## efficient hashing of null-terminated strings
var h: Hash = 0 var h: Hash = 0
var i = 0 var i = 0
when defined(js):
while i < x.len:
h = h !& ord(x[i])
inc i
else:
while x[i] != 0.char: while x[i] != 0.char:
h = h !& ord(x[i]) h = h !& ord(x[i])
inc i inc i