[bugfix] fix OrderedTable default initialization (#11549)
This commit is contained in:
parent
55da84e141
commit
45bbf1ef5b
2 changed files with 3 additions and 2 deletions
|
|
@ -118,6 +118,9 @@ template initImpl(result: typed, size: int) =
|
|||
assert isPowerOfTwo(size)
|
||||
result.counter = 0
|
||||
newSeq(result.data, size)
|
||||
when compiles(result.first):
|
||||
result.first = -1
|
||||
result.last = -1
|
||||
|
||||
template insertImpl() = # for CountTable
|
||||
if t.dataLen == 0: initImpl(t, defaultInitialSize)
|
||||
|
|
|
|||
|
|
@ -1282,8 +1282,6 @@ proc initOrderedTable*[A, B](initialsize = defaultInitialSize): OrderedTable[A,
|
|||
a = initOrderedTable[int, string]()
|
||||
b = initOrderedTable[char, seq[int]]()
|
||||
initImpl(result, initialSize)
|
||||
result.first = -1
|
||||
result.last = -1
|
||||
|
||||
proc toOrderedTable*[A, B](pairs: openArray[(A, B)]): OrderedTable[A, B] =
|
||||
## Creates a new ordered hash table that contains the given ``pairs``.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue