rely on defer to push back a bar
defer is optimized since go 1.14
Vladimir Bauer
3 years ago
| 286 | 286 | var wg sync.WaitGroup |
| 287 | 287 | var popCount int |
| 288 | 288 | rows := make([]io.Reader, 0, height) |
| 289 | pool := make([]*Bar, 0, s.bHeap.Len()) | |
| 290 | 289 | for s.bHeap.Len() > 0 { |
| 291 | 290 | var usedRows int |
| 292 | 291 | b := heap.Pop(&s.bHeap).(*Bar) |
| 309 | 308 | if qb, ok := s.queueBars[b]; ok { |
| 310 | 309 | delete(s.queueBars, b) |
| 311 | 310 | qb.priority = b.priority |
| 312 | pool = append(pool, qb) | |
| 311 | defer heap.Push(&s.bHeap, qb) | |
| 313 | 312 | drop = true |
| 314 | 313 | } else if s.popCompleted && !b.bs.noPop { |
| 315 | 314 | if frame.shutdown > 1 { |
| 325 | 324 | continue |
| 326 | 325 | } |
| 327 | 326 | } |
| 328 | pool = append(pool, b) | |
| 329 | } | |
| 330 | ||
| 331 | for _, b := range pool { | |
| 332 | heap.Push(&s.bHeap, b) | |
| 327 | defer heap.Push(&s.bHeap, b) | |
| 333 | 328 | } |
| 334 | 329 | |
| 335 | 330 | for i := len(rows) - 1; i >= 0; i-- { |