bc-java icon indicating copy to clipboard operation
bc-java copied to clipboard

Replace StringBuffer with StringBuilder

Open stratozero opened this issue 1 year ago • 0 comments

StringBuffer is a synchronized Appendable, useful when more than one publisher is appending text to the same Appendable, but a waste of resources when the object is created and consumed by the same method (e.g. various toString()).

Furthermore, in Java 21+ synchronization interferes with the pinning of virtual threads on the carrier thread, potentially slowing down the application if, while locking an object, a suspendable operation is performed (e.g. IO read / write or Thread.sleep())

stratozero avatar Jul 24 '24 12:07 stratozero