Use sb.length instead of sb.toString().length
ProprietaryCalling toString() on a StringBuilder allocates a snapshot String just to read its length. StringBuilder exposes length directly without the copy.
org. openrewrite. kotlin. performance. UseLengthForStringBuilderSize$KtRecipemod run . --recipe= 'org. openrewrite. kotlin. performance. UseLengthForStringBuilderSize$KtRecipe'Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.