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

Lev Priima lev.priima at oracle.com
Fri Mar 27 20:49:01 UTC 2015


Martin,

You mean it should be like this:
         char[] val = value;    /* avoid getfield opcode */
         int end = val.length;
?

Lev

On 03/27/2015 11:37 PM, Martin Buchholz wrote:
> 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 
> <mailto:lev.priima at oracle.com>> wrote:
>
>     Hi Ivan,
>
>     Thanks! Agree. Updated:
>     http://cr.openjdk.java.net/~lpriima/8071571/1/webrev/
>     <http://cr.openjdk.java.net/%7Elpriima/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 <tel:27.03.2015%2017>: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/
>             <http://cr.openjdk.java.net/%7Elpriima/8071571/0/webrev/>
>
>             46 tests from jdk9/dev/jdk/test/java/lang/String* passed
>             locally.
>
>
>
>




More information about the core-libs-dev mailing list