mirror of https://github.com/japl-lang/japl.git
Fix #25
This commit is contained in:
parent
458dd09e08
commit
22788fad3b
|
@ -35,7 +35,7 @@ type
|
||||||
proc toStr*(obj: ptr Obj): string =
|
proc toStr*(obj: ptr Obj): string =
|
||||||
## Converts a JAPL string into a nim string
|
## Converts a JAPL string into a nim string
|
||||||
var strObj = cast[ptr String](obj)
|
var strObj = cast[ptr String](obj)
|
||||||
for i in 0..strObj.str.len - 1:
|
for i in 0..strObj.len - 1:
|
||||||
result.add(strObj.str[i])
|
result.add(strObj.str[i])
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ proc hash*(self: ptr String): uint64 =
|
||||||
## Implements the FNV-1a hashing algorithm
|
## Implements the FNV-1a hashing algorithm
|
||||||
## for strings
|
## for strings
|
||||||
result = 2166136261u
|
result = 2166136261u
|
||||||
for i in countup(0, self.len):
|
for i in countup(0, self.len-1):
|
||||||
result = result xor uint64(self.str[i])
|
result = result xor uint64(self.str[i])
|
||||||
result *= 16777619
|
result *= 16777619
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue