Auto-suggest StringBuilder optimizations
已回答
IntelliJ makes many suggestions for improving efficiency. It would be nice if this included suggesting replacing:
stringBuilder.append(string.substring(start, end))with the more efficient:
stringBuilder.append(string, start, end)
请先登录再写评论。
Hi Derektom14,
Thanks for the clarification about Kotlin!
I was able to reproduce a lack of quick fix suggestion you observed and created a ticket KTIJ-36533 for the team to take a further look at it. Fell free to follow it to get updates on its progress.
Hi Derektom14.
I tried reproducing your case with the following code:
In my environment, IntelliJ IDEA correctly suggests: “Call to substring() is redundant” and offers to replace it with sb.append(str, start, end) (Check the attached screenshots).
I am currently using IntelliJ IDEA 2025.2.4, and the suggestion is working as expected. If you’re on an older build, I recommend upgrading to the latest IntelliJ IDEA release.
Ah, I'm also using 2025.2.4 and get the same correction suggestion in Java, but not in Kotlin. Does the suggestion need to be updated to also accommodate Kotlin? If so, I expect many other suggestions to need similar updates.