Skip to content

Commit 2f63ebe

Browse files
committed
refactoring: straightforward switch b.shutdown
1 parent 50adf0a commit 2f63ebe

1 file changed

Lines changed: 17 additions & 23 deletions

File tree

progress.go

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -400,16 +400,29 @@ func (s *pState) render() (err error) {
400400
switch b.shutdown {
401401
case 1:
402402
b.cancel(nil)
403-
s.onShutdown(b, frame, offload)
403+
if q, ok := s.queueBars[b]; ok {
404+
delete(s.queueBars, b)
405+
q.priority = b.priority
406+
s.hm.push(q, true, offload)
407+
continue
408+
}
409+
if s.popCompleted && !frame.noPop {
410+
b.priority = s.popPriority
411+
s.popPriority++
412+
frame.rmOnComplete = false
413+
}
414+
if frame.rmOnComplete {
415+
s.hasUnrendered = true
416+
continue
417+
}
404418
case 2:
405419
if s.popCompleted && !frame.noPop {
406420
popCount += len(frame.rows) - discarded
407421
continue
408422
}
409-
fallthrough
410-
default:
411-
s.hm.push(b, false, offload)
412423
}
424+
425+
s.hm.push(b, false, offload)
413426
}
414427

415428
for _, row := range slices.Backward(rows) {
@@ -427,25 +440,6 @@ func (s *pState) render() (err error) {
427440
return s.cwriter.Flush(total - popCount)
428441
}
429442

430-
func (s *pState) onShutdown(b *Bar, frame *renderFrame, offload chan<- heapRequest) {
431-
if q, ok := s.queueBars[b]; ok {
432-
delete(s.queueBars, b)
433-
q.priority = b.priority
434-
s.hm.push(q, true, offload)
435-
return
436-
}
437-
if s.popCompleted && !frame.noPop {
438-
b.priority = s.popPriority
439-
s.popPriority++
440-
frame.rmOnComplete = false
441-
}
442-
if !frame.rmOnComplete {
443-
s.hm.push(b, false, offload)
444-
} else {
445-
s.hasUnrendered = true
446-
}
447-
}
448-
449443
func (s *pState) makeBarState(total int64, filler BarFiller, options ...BarOption) *bState {
450444
bs := &bState{
451445
id: s.idCount,

0 commit comments

Comments
 (0)