Skip to content

Commit 7efde3c

Browse files
committed
make [][]io.Reader with capacity
1 parent 0675e6b commit 7efde3c

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

progress.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,16 +355,18 @@ func (s *pState) render(cw *cwriter.Writer) (err error) {
355355
height = width
356356
}
357357

358+
var barCount int
358359
for b := range iter {
360+
barCount++
359361
go b.render(width)
360362
}
361363

362-
return s.flush(cw, height, iterPop)
364+
return s.flush(cw, height, barCount, iterPop)
363365
}
364366

365-
func (s *pState) flush(cw *cwriter.Writer, height int, iter <-chan *Bar) error {
367+
func (s *pState) flush(cw *cwriter.Writer, height, barCount int, iter <-chan *Bar) error {
366368
var total, popCount int
367-
var rows [][]io.Reader
369+
rows := make([][]io.Reader, 0, barCount)
368370

369371
for b := range iter {
370372
frame := <-b.frameCh

0 commit comments

Comments
 (0)