[bugfix] fix OrderedTable default initialization (#11549)

This commit is contained in:
Miran
2019-06-20 21:03:11 +02:00
committed by Andreas Rumpf
parent 55da84e141
commit 45bbf1ef5b
2 changed files with 3 additions and 2 deletions

View File

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

View File

@@ -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``.