Refactor: maxWidth
Vladimir Bauer
8 years ago
| 165 | 165 | ws.Distributor[i] = make(chan int, numBars) |
| 166 | 166 | } |
| 167 | 167 | for i := 0; i < numColumn; i++ { |
| 168 | go func(accumulator <-chan int, discharger chan<- int) { | |
| 169 | defer close(discharger) | |
| 168 | go func(accumulator <-chan int, distributor chan<- int) { | |
| 169 | defer close(distributor) | |
| 170 | 170 | widths := make([]int, 0, numBars) |
| 171 | 171 | loop: |
| 172 | 172 | for { |
| 183 | 183 | break loop |
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | result := max(widths) | |
| 186 | maxWidth := calcMax(widths) | |
| 187 | 187 | for i := 0; i < len(widths); i++ { |
| 188 | discharger <- result | |
| 188 | distributor <- maxWidth | |
| 189 | 189 | } |
| 190 | 190 | }(ws.Accumulator[i], ws.Distributor[i]) |
| 191 | 191 | } |
| 235 | 235 | return slice |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | func max(slice []int) int { | |
| 238 | func calcMax(slice []int) int { | |
| 239 | 239 | max := slice[0] |
| 240 | 240 | |
| 241 | 241 | for i := 1; i < len(slice); i++ { |