RFR: 8071571: Move substring of same string to slow path

Martin Buchholz martinrb at google.com
Fri Mar 27 20:37:23 UTC 2015


Here you copy the field into a local, but then don't make use of it to grab
the length.


2888         int len = value.length;
2889         int st = 0;
2890         char[] val = value;    /* avoid getfield opcode */

Also, 'beg' and 'end' would be much better names for the locals 'st' and
'len'.

On Fri, Mar 27, 2015 at 12:54 PM, Lev Priima <lev.priima at oracle.com> wrote:

> Hi Ivan,
>
> Thanks! Agree. Updated: http://cr.openjdk.java.net/~
> lpriima/8071571/1/webrev/
>
> Lev
>
>
> On 03/27/2015 06:17 PM, Ivan Gerasimov wrote:
>
>> Hi Lev!
>>
>> Why don't you want to also simplify String#trim()?
>> -        return ((st > 0) || (len < value.length)) ? substring(st, len) :
>> this;
>> +        return substring(st, len);
>>
>> I guess, the situation when a string *is* trimmed, i.e. substring() is
>> called is more common.
>> In that case we have a couple of duplicating condition checks (they're
>> going to be performed in substring() anyways) plus the cost of a branch.
>>
>> Sincerely yours,
>> Ivan
>>
>>
>> On 27.03.2015 17:56, Lev Priima wrote:
>>
>>> Please review small cleanup in java.lang.String:
>>>
>>> Issue: https://bugs.openjdk.java.net/browse/JDK-8071571
>>> Webrev: http://cr.openjdk.java.net/~lpriima/8071571/0/webrev/
>>>
>>> 46 tests from jdk9/dev/jdk/test/java/lang/String* passed locally.
>>>
>>>
>>
>



More information about the core-libs-dev mailing list