diff --git a/progress.go b/progress.go index ec795d9..e09d8f1 100644 --- a/progress.go +++ b/progress.go @@ -289,6 +289,7 @@ var wg sync.WaitGroup var popCount int rows := s.rows[:0] + pool := make([]*Bar, 0, s.bHeap.Len()) for s.bHeap.Len() > 0 { var usedRows int b := heap.Pop(&s.bHeap).(*Bar) @@ -315,7 +316,7 @@ if qb, ok := s.queueBars[b]; ok { delete(s.queueBars, b) qb.priority = b.priority - defer heap.Push(&s.bHeap, qb) + pool = append(pool, qb) drop = true } else if s.popCompleted && !b.bs.noPop { if frame.shutdown > 1 { @@ -331,7 +332,11 @@ continue } } - defer heap.Push(&s.bHeap, b) + pool = append(pool, b) + } + + for _, b := range pool { + heap.Push(&s.bHeap, b) } for i := len(rows) - 1; i >= 0; i-- {