refactoring: (*bFiller).Fill
prefer switch to if, which allows some dry code
Vladimir Bauer
1 year, 11 months ago
| 240 | 240 | s.tip.count++ |
| 241 | 241 | fillCount += tip.width |
| 242 | 242 | } |
| 243 | if stat.Refill != 0 { | |
| 244 | refWidth := int(internal.PercentageRound(stat.Total, stat.Refill, uint(width))) | |
| 243 | switch refWidth := 0; { | |
| 244 | case stat.Refill != 0: | |
| 245 | refWidth = int(internal.PercentageRound(stat.Total, stat.Refill, uint(width))) | |
| 245 | 246 | curWidth -= refWidth |
| 246 | 247 | refWidth += curWidth |
| 248 | fallthrough | |
| 249 | default: | |
| 247 | 250 | for w := s.components[iFiller].width; curWidth-fillCount >= w; fillCount += w { |
| 248 | 251 | filling = append(filling, s.components[iFiller].bytes...) |
| 249 | 252 | } |
| 250 | 253 | for w := s.components[iRefiller].width; refWidth-fillCount >= w; fillCount += w { |
| 251 | 254 | refilling = append(refilling, s.components[iRefiller].bytes...) |
| 252 | } | |
| 253 | } else { | |
| 254 | for w := s.components[iFiller].width; curWidth-fillCount >= w; fillCount += w { | |
| 255 | filling = append(filling, s.components[iFiller].bytes...) | |
| 256 | 255 | } |
| 257 | 256 | } |
| 258 | 257 | } |