RFR: JDK-8302323 Add repeat methods to StringBuilder/StringBuffer [v8]
Jim Laskey
jlaskey at openjdk.org
Mon Mar 27 18:37:14 UTC 2023
On Tue, 14 Mar 2023 10:14:44 GMT, Claes Redestad <redestad at openjdk.org> wrote:
>> Jim Laskey has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Expand test for StringBuffer and illegal code points
>
> src/java.base/share/classes/java/lang/AbstractStringBuilder.java line 1832:
>
>> 1830: if (isLatin1 && StringLatin1.canEncode(c)) {
>> 1831: byte b = (byte)c;
>> 1832: for (int index = this.count; index < limit; index++) {
>
> This loop could even be replaced with `Arrays.fill(value, this.count, limit, b)` - a plausible candidate for intrinsification? There's an added range check in that method, however, but that shouldn't be too hard for the JIT to eliminate.
I bounded back and forth on this one. Performance is a little give and take. Will use Arrays.fill for maintainability.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/12728#discussion_r1149648398
More information about the core-libs-dev
mailing list