From 72d6b59ffa93060386888ffdd333baaab28a8483 Mon Sep 17 00:00:00 2001 From: Clyybber Date: Sun, 9 May 2021 00:56:37 +0200 Subject: [PATCH] treetab: tiny cleanup (#17929) * treetab: tiny cleanup * Another tiny thing * Explicitly move n Co-authored-by: Andreas Rumpf * Typo Co-authored-by: Andreas Rumpf --- compiler/treetab.nim | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/compiler/treetab.nim b/compiler/treetab.nim index 7773b68e1d5a..26afd102c853 100644 --- a/compiler/treetab.nim +++ b/compiler/treetab.nim @@ -86,12 +86,11 @@ proc nodeTablePut*(t: var TNodeTable, key: PNode, val: int) = t.data[index].val = val else: if mustRehash(t.data.len, t.counter): - var n: TNodePairSeq - newSeq(n, t.data.len * GrowthFactor) + var n = newSeq[TNodePair](t.data.len * GrowthFactor) for i in 0..high(t.data): if t.data[i].key != nil: nodeTableRawInsert(n, t.data[i].h, t.data[i].key, t.data[i].val) - swap(t.data, n) + t.data = move n nodeTableRawInsert(t.data, k, key, val) inc(t.counter) @@ -103,12 +102,11 @@ proc nodeTableTestOrSet*(t: var TNodeTable, key: PNode, val: int): int = result = t.data[index].val else: if mustRehash(t.data.len, t.counter): - var n: TNodePairSeq - newSeq(n, t.data.len * GrowthFactor) + var n = newSeq[TNodePair](t.data.len * GrowthFactor) for i in 0..high(t.data): if t.data[i].key != nil: nodeTableRawInsert(n, t.data[i].h, t.data[i].key, t.data[i].val) - swap(t.data, n) + t.data = move n nodeTableRawInsert(t.data, k, key, val) result = val inc(t.counter)