fixes deepcopy regression
This commit is contained in:
parent
8875ca750f
commit
7c1b5b3c2b
1 changed files with 4 additions and 2 deletions
|
|
@ -13,10 +13,12 @@ type
|
||||||
data: array[0..0xff_ffff, (pointer, pointer)]
|
data: array[0..0xff_ffff, (pointer, pointer)]
|
||||||
|
|
||||||
template hashPtr(key: pointer): int = cast[int](key) shr 8
|
template hashPtr(key: pointer): int = cast[int](key) shr 8
|
||||||
|
template allocPtrTable: untyped =
|
||||||
|
cast[PtrTable](alloc0(sizeof(int)*2 + sizeof(pointer)*2*cap))
|
||||||
|
|
||||||
proc rehash(t: PtrTable): PtrTable =
|
proc rehash(t: PtrTable): PtrTable =
|
||||||
let cap = (t.max+1) * 2
|
let cap = (t.max+1) * 2
|
||||||
result = cast[PtrTable](alloc0(sizeof(int)*2 + sizeof(pointer)*cap))
|
result = allocPtrTable()
|
||||||
result.counter = t.counter
|
result.counter = t.counter
|
||||||
result.max = cap-1
|
result.max = cap-1
|
||||||
for i in 0..t.max:
|
for i in 0..t.max:
|
||||||
|
|
@ -29,7 +31,7 @@ proc rehash(t: PtrTable): PtrTable =
|
||||||
|
|
||||||
proc initPtrTable(): PtrTable =
|
proc initPtrTable(): PtrTable =
|
||||||
const cap = 32
|
const cap = 32
|
||||||
result = cast[PtrTable](alloc0(sizeof(int)*2 + sizeof(pointer)*cap))
|
result = allocPtrTable()
|
||||||
result.counter = 0
|
result.counter = 0
|
||||||
result.max = cap-1
|
result.max = cap-1
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue