diff options
author | Clyybber <darkmine956@gmail.com> | 2021-05-09 00:56:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-09 00:56:37 +0200 |
commit | 72d6b59ffa93060386888ffdd333baaab28a8483 (patch) | |
tree | bcabfcafbdf0f247b2d94a49f47afa56b2f8e96c | |
parent | 4e0f38fbb12c8b7faf56bb71846f0b4178ed6470 (diff) | |
download | Nim-72d6b59ffa93060386888ffdd333baaab28a8483.tar.gz |
treetab: tiny cleanup (#17929)
* treetab: tiny cleanup * Another tiny thing * Explicitly move n Co-authored-by: Andreas Rumpf <rumpf_a@web.de> * Typo Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
-rw-r--r-- | compiler/treetab.nim | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/compiler/treetab.nim b/compiler/treetab.nim index 7773b68e1..26afd102c 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) |