mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 01:14:41 +00:00
[bugfix] fix OrderedTable default initialization (#11549)
This commit is contained in:
@@ -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``.
|
||||
|
||||
Reference in New Issue
Block a user