Replace java.lang.StringBuffer with java.lang.StringBuilder
ProprietaryStringBuffer synchronizes every operation, which only costs time when a single thread uses it. This recipe replaces a StringBuffer that a method creates and keeps in a local variable with a StringBuilder, which has the same methods without the synchronization, when program analysis shows that no other thread can reach it: it is not returned, stored in a field, passed to another method or constructor, or captured by a lambda that may run later or on another thread, by any path through the method, loops and catch blocks included. Fields, and Kotlin and other non-Java source, are left as they are.
io. moderne. staticanalysis. ReplaceStringBufferWithStringBuildermod run . --recipe= io. moderne. staticanalysis. ReplaceStringBufferWithStringBuilderInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.