Skip to content

Commit

Permalink
no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
planetis-m committed May 1, 2024
1 parent 39b54bb commit 1a49975
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/jsonpak/jsonptr.nim
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,10 @@ proc getArrayIndex(token: string): int =
except ValueError:
raiseSyntaxError(token)

template copyTokenToBuffer(buf, src, first, last) =
template copySubStr(buf, src, first, last) =
buf.setLen(last-first)
when nimvm:
for i in 0..high(buf):
buf[i] = src[i+first]
else:
if first < last:
copyMem(cstring(buf), addr src[first], buf.len)
for i in 0..high(buf):
buf[i] = src[i+first]

proc findNode*(tree: JsonTree, path: string): NodePos =
var
Expand All @@ -111,7 +107,7 @@ proc findNode*(tree: JsonTree, path: string): NodePos =
var first = last
while last < len(path) and path[last] != '/':
inc(last)
copyTokenToBuffer(cur, path, first, last)
copySubStr(cur, path, first, last)

case n.kind
of opcodeObject:
Expand Down Expand Up @@ -152,7 +148,7 @@ proc findNodeMut*(tree: JsonTree, path: string): PathResult =
var first = last
while last < len(path) and path[last] != '/':
inc(last)
copyTokenToBuffer(cur, path, first, last)
copySubStr(cur, path, first, last)

case n.kind
of opcodeObject:
Expand Down

0 comments on commit 1a49975

Please sign in to comment.