Skip to content

Commit 2dcb25d

Browse files
committed
refactoring tryEarlyRefresh
1 parent d078269 commit 2dcb25d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

bar.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -460,12 +460,15 @@ func (b *Bar) triggerCompletion(s *bState) {
460460
}
461461

462462
func (b *Bar) tryEarlyRefresh(renderReq chan<- time.Time) {
463-
var anyOtherRunning bool
463+
var otherRunning int
464464
b.container.traverseBars(func(bar *Bar) bool {
465-
anyOtherRunning = b != bar && bar.IsRunning()
466-
return anyOtherRunning
465+
if b != bar && bar.IsRunning() {
466+
otherRunning++
467+
return false // stop traverse
468+
}
469+
return true // continue traverse
467470
})
468-
if !anyOtherRunning {
471+
if otherRunning == 0 {
469472
for {
470473
select {
471474
case renderReq <- time.Now():

progress.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (p *Progress) traverseBars(cb func(b *Bar) bool) {
194194
select {
195195
case p.operateState <- func(s *pState) { s.hm.iter(iter, drop) }:
196196
for b := range iter {
197-
if cb(b) {
197+
if !cb(b) {
198198
close(drop)
199199
break
200200
}

0 commit comments

Comments
 (0)