RFR: 8264029: Replace uses of StringBuffer with StringBuilder in java.base
Pavel Rappo
prappo at openjdk.java.net
Tue Mar 23 21:57:39 UTC 2021
On Tue, 23 Mar 2021 20:44:17 GMT, Andrey Turbanov <github.com+741251+turbanoff at openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java line 1954:
>>
>>> 1952: for (int i = 0; i < 4; ++i) {
>>> 1953: if (i > 0) {
>>> 1954: sb.append(" ");
>>
>> Consider using `String.repeat` here and on L1960 for clarity.
>
> I'm not sure how String.repeat can be used here. Repeated String is not constant and different for each iteration.
Long runs of whitespace, especially in blank strings, may have poor readability. I was thinking that
" ".repeat(7) and " ".repeat(10)
might read better than
" " and " "
respectively. If you don't agree, then simply disregard what I said. If you agree but worry about negative performance implications, consider creating these strings before the respective for-loops.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2922
More information about the core-libs-dev
mailing list