reuse rows slice
Vladimir Bauer
3 years ago
| 39 | 39 | heapUpdated bool |
| 40 | 40 | pMatrix map[int][]chan int |
| 41 | 41 | aMatrix map[int][]chan int |
| 42 | rows []io.Reader | |
| 42 | 43 | |
| 43 | 44 | // following are provided/overrided by user |
| 44 | 45 | idCount int |
| 68 | 69 | func NewWithContext(ctx context.Context, options ...ContainerOption) *Progress { |
| 69 | 70 | s := &pState{ |
| 70 | 71 | bHeap: priorityQueue{}, |
| 72 | rows: make([]io.Reader, 128), | |
| 71 | 73 | rr: prr, |
| 72 | 74 | queueBars: make(map[*Bar]*Bar), |
| 73 | 75 | output: os.Stdout, |
| 285 | 287 | func (s *pState) flush(cw *cwriter.Writer, height int) error { |
| 286 | 288 | var wg sync.WaitGroup |
| 287 | 289 | var popCount int |
| 288 | rows := make([]io.Reader, 0, height) | |
| 290 | rows := s.rows[:0] | |
| 289 | 291 | for s.bHeap.Len() > 0 { |
| 290 | 292 | var usedRows int |
| 291 | 293 | b := heap.Pop(&s.bHeap).(*Bar) |