* fix #13310, Deque misbehaves on VM * use 'when nimVM'
This commit is contained in:
parent
281e02fc79
commit
70bd41dae0
1 changed files with 15 additions and 2 deletions
|
|
@ -274,8 +274,9 @@ proc expandIfNeeded[T](deq: var Deque[T]) =
|
||||||
if unlikely(deq.count >= cap):
|
if unlikely(deq.count >= cap):
|
||||||
var n = newSeq[T](cap * 2)
|
var n = newSeq[T](cap * 2)
|
||||||
var i = 0
|
var i = 0
|
||||||
for x in mitems(deq): # don't use copyMem because of the GC and because it's slower.
|
for x in mitems(deq):
|
||||||
n[i] = move(x)
|
when nimVM: n[i] = x # workaround for VM bug
|
||||||
|
else: n[i] = move(x)
|
||||||
inc i
|
inc i
|
||||||
deq.data = move(n)
|
deq.data = move(n)
|
||||||
deq.mask = cap * 2 - 1
|
deq.mask = cap * 2 - 1
|
||||||
|
|
@ -569,3 +570,15 @@ when isMainModule:
|
||||||
foo(2, 1)
|
foo(2, 1)
|
||||||
foo(1, 5)
|
foo(1, 5)
|
||||||
foo(3, 2)
|
foo(3, 2)
|
||||||
|
|
||||||
|
import sets
|
||||||
|
block t13310:
|
||||||
|
proc main() =
|
||||||
|
var q = initDeque[HashSet[int16]](2)
|
||||||
|
q.addFirst([1'i16].toHashSet)
|
||||||
|
q.addFirst([2'i16].toHashSet)
|
||||||
|
q.addFirst([3'i16].toHashSet)
|
||||||
|
assert $q == "[{3}, {2}, {1}]"
|
||||||
|
|
||||||
|
static:
|
||||||
|
main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue