From 39b54bb420d999a6eb8c67fb66c1b3adaec240e9 Mon Sep 17 00:00:00 2001 From: Antonis Geralis Date: Wed, 1 May 2024 18:54:33 +0300 Subject: [PATCH] revert last commit --- src/jsonpak/private/rawops.nim | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/jsonpak/private/rawops.nim b/src/jsonpak/private/rawops.nim index 21f2a9d..2e1245c 100644 --- a/src/jsonpak/private/rawops.nim +++ b/src/jsonpak/private/rawops.nim @@ -60,19 +60,13 @@ proc rawAddKeyValuePair*(result: var JsonTree, src, dest: NodePos, key: string) let L = span(result, src.int) + 1 let oldfull = result.nodes.len setLen(result.nodes, oldfull+L) - when nimvm: - for i in countdown(oldfull-1, dest.int): - result.nodes[i+L] = result.nodes[i] - else: - moveMem(addr result.nodes[dest.int+L], addr result.nodes[dest.int], (oldfull-dest.int)*sizeof(Node)) + for i in countdown(oldfull-1, dest.int): + result.nodes[i+L] = result.nodes[i] result.nodes[dest.int] = toAtomNode(result, opcodeString, key) let src = if src >= dest: NodePos(src.int+L) else: src - when nimvm: - for i in 0.. 0: # Expand the nodes sequence if the new value is larger setLen(result.nodes, oldfull+diff) - when nimvm: - for i in countdown(oldfull-1, endpos): - result.nodes[i+diff] = result.nodes[i] - else: - moveMem(addr result.nodes[endpos+diff], addr result.nodes[endpos], (oldfull-endpos)*sizeof(Node)) + for i in countdown(oldfull-1, endpos): + result.nodes[i+diff] = result.nodes[i] elif diff < 0: # Shrink the nodes sequence if the new value is smaller - when nimvm: - for i in countup(endpos, oldfull-1): - result.nodes[i+diff] = result.nodes[i] - else: - moveMem(addr result.nodes[endpos+diff], addr result.nodes[endpos], (oldfull-endpos)*sizeof(Node)) + for i in countup(endpos, oldfull-1): + result.nodes[i+diff] = result.nodes[i] setLen(result.nodes, oldfull+diff) # Copy the new nodes into the nodes sequence for i in 0..