build(deps): bump github.com/vbauerster/mpb/v8 from 8.1.4 to 8.1.6

Bumps [github.com/vbauerster/mpb/v8](https://github.com/vbauerster/mpb) from 8.1.4 to 8.1.6.
- [Release notes](https://github.com/vbauerster/mpb/releases)
- [Commits](https://github.com/vbauerster/mpb/compare/v8.1.4...v8.1.6)

---
updated-dependencies:
- dependency-name: github.com/vbauerster/mpb/v8
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2023-02-08 12:04:11 +00:00
committed by GitHub
parent 4368c587b0
commit ded44be160
7 changed files with 20 additions and 36 deletions

View File

@@ -23,7 +23,7 @@ func (s percentageType) Format(st fmt.State, verb rune) {
}
}
p := bytePool.Get().(*[]byte)
p := bytesPool.Get().(*[]byte)
b := strconv.AppendFloat(*p, float64(s), 'f', prec, 64)
if st.Flag(' ') {
b = append(b, ' ', '%')
@@ -34,7 +34,7 @@ func (s percentageType) Format(st fmt.State, verb rune) {
if err != nil {
panic(err)
}
bytePool.Put(p)
bytesPool.Put(p)
}
// Percentage returns percentage decorator. It's a wrapper of NewPercentage.

View File

@@ -2,9 +2,9 @@ package decor
import "sync"
var bytePool = sync.Pool{
var bytesPool = sync.Pool{
New: func() interface{} {
b := make([]byte, 0, 16)
b := make([]byte, 0, 32)
return &b
},
}

View File

@@ -49,7 +49,7 @@ func (self SizeB1024) Format(st fmt.State, verb rune) {
unit = _iTiB
}
p := bytePool.Get().(*[]byte)
p := bytesPool.Get().(*[]byte)
b := strconv.AppendFloat(*p, float64(self)/float64(unit), 'f', prec, 64)
if st.Flag(' ') {
b = append(b, ' ')
@@ -59,7 +59,7 @@ func (self SizeB1024) Format(st fmt.State, verb rune) {
if err != nil {
panic(err)
}
bytePool.Put(p)
bytesPool.Put(p)
}
const (
@@ -103,7 +103,7 @@ func (self SizeB1000) Format(st fmt.State, verb rune) {
unit = _TB
}
p := bytePool.Get().(*[]byte)
p := bytesPool.Get().(*[]byte)
b := strconv.AppendFloat(*p, float64(self)/float64(unit), 'f', prec, 64)
if st.Flag(' ') {
b = append(b, ' ')
@@ -113,5 +113,5 @@ func (self SizeB1000) Format(st fmt.State, verb rune) {
if err != nil {
panic(err)
}
bytePool.Put(p)
bytesPool.Put(p)
}

View File

@@ -39,10 +39,7 @@ type pState struct {
heapUpdated bool
pMatrix map[int][]chan int
aMatrix map[int][]chan int
// for reuse purposes
rows []io.Reader
pool []*Bar
rows []io.Reader
// following are provided/overrided by user
refreshRate time.Duration
@@ -72,8 +69,7 @@ func New(options ...ContainerOption) *Progress {
// method has been called.
func NewWithContext(ctx context.Context, options ...ContainerOption) *Progress {
s := &pState{
rows: make([]io.Reader, 0, 64),
pool: make([]*Bar, 0, 64),
rows: make([]io.Reader, 32),
refreshRate: defaultRefreshRate,
popPriority: math.MinInt32,
manualRefresh: make(chan interface{}),
@@ -275,9 +271,6 @@ func (p *Progress) serve(s *pState, cw *cwriter.Writer) {
defer close(p.shutdown)
render := func() error {
if s.bHeap.Len() == 0 {
return nil
}
return s.render(cw)
}
@@ -336,6 +329,8 @@ func (s *pState) render(cw *cwriter.Writer) error {
func (s *pState) flush(wg *sync.WaitGroup, cw *cwriter.Writer, height int) error {
var popCount int
pool := make([]*Bar, 0, s.bHeap.Len())
s.rows = s.rows[:0]
for s.bHeap.Len() > 0 {
b := heap.Pop(&s.bHeap).(*Bar)
@@ -362,7 +357,7 @@ func (s *pState) flush(wg *sync.WaitGroup, cw *cwriter.Writer, height int) error
if qb, ok := s.queueBars[b]; ok {
delete(s.queueBars, b)
qb.priority = b.priority
s.pool = append(s.pool, qb)
pool = append(pool, qb)
s.heapUpdated = true
continue
}
@@ -383,25 +378,15 @@ func (s *pState) flush(wg *sync.WaitGroup, cw *cwriter.Writer, height int) error
continue
}
}
s.pool = append(s.pool, b)
pool = append(pool, b)
}
switch len(s.pool) {
case 0:
if s.heapUpdated {
s.updateSyncMatrix()
s.heapUpdated = false
}
case 1:
heap.Push(&s.bHeap, s.pool[0])
s.pool = s.pool[:0]
default:
if len(pool) != 0 {
wg.Add(1)
go func() {
for _, b := range s.pool {
for _, b := range pool {
heap.Push(&s.bHeap, b)
}
s.pool = s.pool[:0]
wg.Done()
}()
}
@@ -414,7 +399,6 @@ func (s *pState) flush(wg *sync.WaitGroup, cw *cwriter.Writer, height int) error
}
err := cw.Flush(len(s.rows) - popCount)
s.rows = s.rows[:0]
return err
}