ctongfei / progressbar

Terminal-based progress bar for Java / JVM
http://tongfei.me/progressbar/
MIT License
1.07k stars 102 forks source link

Create StringBuilder with known size of string #107

Closed heroesleo65 closed 3 years ago

heroesleo65 commented 3 years ago

Result of string does have length equal to given argument maxLength in DefaultProgressBarRenderer.render always. We can use this and create StringBuilder with initial size of array equal to maxLength

ctongfei commented 3 years ago

It might not be exactly the same as maxLength (various reasons, e.g. East Asian chars). But this fix is good for the performance. Thanks!