refactoring: defer inside if
Vladimir Bauer
7 years ago
| 264 | 264 | bm := make(map[*Bar]struct{}, s.bHeap.Len()) |
| 265 | 265 | for s.bHeap.Len() > 0 { |
| 266 | 266 | b := heap.Pop(&s.bHeap).(*Bar) |
| 267 | defer func() { | |
| 268 | if b.toShutdown { | |
| 269 | // shutdown at next flush, in other words decrement underlying WaitGroup | |
| 270 | // only after the bar with completed state has been flushed. this | |
| 271 | // ensures no bar ends up with less than 100% rendered. | |
| 267 | cw.ReadFrom(<-b.frameCh) | |
| 268 | if b.toShutdown { | |
| 269 | // shutdown at next flush | |
| 270 | // this ensures no bar ends up with less than 100% rendered | |
| 271 | defer func() { | |
| 272 | 272 | s.barShutdownQueue = append(s.barShutdownQueue, b) |
| 273 | 273 | if !b.noPop && s.popCompleted { |
| 274 | 274 | b.priority = -1 |
| 275 | 275 | } |
| 276 | } | |
| 277 | }() | |
| 278 | cw.ReadFrom(<-b.frameCh) | |
| 276 | }() | |
| 277 | } | |
| 279 | 278 | lineCount += b.extendedLines + 1 |
| 280 | 279 | bm[b] = struct{}{} |
| 281 | 280 | } |