Skip to content

Commit

Permalink
populateEwmaDecorators at makeBarState
Browse files Browse the repository at this point in the history
  • Loading branch information
vbauerster committed Feb 21, 2025
1 parent 10b8f02 commit 2fde7a8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions bar.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,12 @@ func (s *bState) wSyncTable() (table syncTable) {
return table
}

func (s *bState) populateEwmaDecorators(decorators []decor.Decorator) {
for _, d := range decorators {
if d, ok := unwrap(d).(decor.EwmaDecorator); ok {
s.ewmaDecorators = append(s.ewmaDecorators, d)
func (s *bState) populateEwmaDecorators() {
for _, group := range s.decorGroups {
for _, d := range group {
if d, ok := unwrap(d).(decor.EwmaDecorator); ok {
s.ewmaDecorators = append(s.ewmaDecorators, d)
}
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions bar_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ func PrependDecorators(decorators ...decor.Decorator) BarOption {
}
}
return func(s *bState) {
s.populateEwmaDecorators(group)
s.decorGroups[0] = group
}
}
Expand All @@ -33,7 +32,6 @@ func AppendDecorators(decorators ...decor.Decorator) BarOption {
}
}
return func(s *bState) {
s.populateEwmaDecorators(group)
s.decorGroups[1] = group
}
}
Expand Down
2 changes: 2 additions & 0 deletions progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ func (s pState) makeBarState(total int64, filler BarFiller, options ...BarOption
}
}

bs.populateEwmaDecorators()

bs.buffers[0] = bytes.NewBuffer(make([]byte, 0, 128)) // prepend
bs.buffers[1] = bytes.NewBuffer(make([]byte, 0, 128)) // append
bs.buffers[2] = bytes.NewBuffer(make([]byte, 0, 256)) // filler
Expand Down

0 comments on commit 2fde7a8

Please sign in to comment.