RFR: JDK-8302323 Add repeat methods to StringBuilder/StringBuffer
Raffaello Giulietti
rgiulietti at openjdk.org
Thu Feb 23 15:43:21 UTC 2023
On Thu, 23 Feb 2023 15:32:36 GMT, Jim Laskey <jlaskey at openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/AbstractStringBuilder.java line 1851:
>>
>>> 1849: while (count-- != 0) {
>>> 1850: value[index++] = (byte) c;
>>> 1851: }
>>
>> One could reduce to just one running var rather than two:
>>
>> int index = this.count;
>> int limit = index + count;
>> for (; index != limit; ++index) {
>> value[index] = (byte) c;
>> }
>
> True. Will test to see if there is any performance benefit.
Apart from perf, the less "moving parts" there are, the better I personally understand code ;-)
-------------
PR: https://git.openjdk.org/jdk/pull/12728
More information about the core-libs-dev
mailing list