Progress.swift
Progress.swift copied to clipboard
fix off-by-one counting error
The progress meter never actually made it to 100%.
Tested as follows:
var progress = ProgressBar(count: 5)
for i in 0..<5 {
print("printing \(i)")
progress.next()
}
which produced the following output:
printing 0
0 of 5 Consolidating entries: [ ] 0% ETA: 00:00:00 (at 0.00) it/s)
printing 1
printing 2
printing 3
printing 4
4 of 5 Consolidating entries: [------------------------ ] 80% ETA: 00:00:00 (at 85163.53) it/s)
This is because the code was comparing 0-based indices with counts of objects processed and left to process. The 0-based index would always be 1 less than the count, so progress would never get to 100%.