mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
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>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user