On Mon, 30 Aug 2021 14:52:12 GMT, Claes Redestad <[email protected]> wrote:
>> What about lines 582, 1003 and 1175? E.g. 582
>>
>> public AbstractStringBuilder append(String str) {
>> if (str == null) {
>> return appendNull();
>> }
>> int len = str.length();
>> ensureCapacityInternal(count + len);
>> putStringAt(count, str); // couldn't it be
>> putStringAt(count, str, 0, len);
>> count += len;
>> return this;
>> }
>>
>> Doing this here and in other places allows to rid `private void
>> putStringAt(int index, String str)` completely and reduce one nested method
>> call, right?
>
> I think you've got the wrong idea: We _want_ to use `putStringAt(int,
> String)` now since it can call into `String.getBytes(String, int, byte)`,
> which has a simpler and more efficient implementation than
> `String.getBytes(String, int, int, byte, int)`, since it avoids a couple of
> `<< coder` operations. This makes up for most of the improvement between my
> initial and the current version of this patch.
>
> (There's also no nested delegation from `putStringAt(int, String)` to
> `putStringAt(int, String, int, int)` in my proposed patch.)
You are right, I've applied your patch locally incompletely and misunderstood
it, my bad :)
-------------
PR: https://git.openjdk.java.net/jdk/pull/5291