Skip to content

Commit

Permalink
treetab: tiny cleanup (#17929)
Browse files Browse the repository at this point in the history
* treetab: tiny cleanup

* Another tiny thing

* Explicitly move n

Co-authored-by: Andreas Rumpf <[email protected]>

* Typo

Co-authored-by: Andreas Rumpf <[email protected]>
  • Loading branch information
Clyybber and Araq authored May 8, 2021
1 parent 4e0f38f commit 72d6b59
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions compiler/treetab.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

0 comments on commit 72d6b59

Please sign in to comment.