RFR: JDK-8200380 String::lines

Jim Laskey james.laskey at oracle.com
Fri May 18 18:50:57 UTC 2018


Made the change to 1) already (based on Paul’s remarks)

2) skipLineSeparator needs to handle the end of string with no terminator case (start == fence.)  Could change it but then would have to change other code around.
 

> On May 18, 2018, at 3:33 PM, Xueming Shen <xueming.shen at oracle.com> wrote:
> 
> On 5/18/18, 6:44 AM, Jim Laskey wrote:
>> 
>> String::lines instance method that returns a Stream<String> with elements composed of substrings from the original string delimited by any recognized new line character sequence.
>> 
>> webrev: http://cr.openjdk.java.net/~jlaskey/8200380/webrev/index.html <http://cr.openjdk.java.net/~jlaskey/8200380/webrev/index.html> <http://cr.openjdk.java.net/~jlaskey/8200380/webrev/index.html> <http://cr.openjdk.java.net/~jlaskey/8200380/webrev/index.html>
>> bug: https://bugs.openjdk.java.net/browse/JDK-8200380 <https://bugs.openjdk.java.net/browse/JDK-8200380> <https://bugs.openjdk.java.net/browse/JDK-8200380> <https://bugs.openjdk.java.net/browse/JDK-8200380>
>> csr: https://bugs.openjdk.java.net/browse/JDK-8200425 <https://bugs.openjdk.java.net/browse/JDK-8200425> <https://bugs.openjdk.java.net/browse/JDK-8200425> <https://bugs.openjdk.java.net/browse/JDK-8200425>
>> 
>> 
> (1) seems like we probably don' t need the "cs" field, and do ?
>        @Override
>         public int characteristics() {
>             return Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL;
> 
> (2) 
>   622         private int skipLineSeparator(int start) {
>  623             if (start < fence) {
>  624                 if (value[start] == '\r') {
>  625                     int next = start + 1;
>  626                     if (next < fence && value[next] == '\n') {
>  627                         return next + 1;
>  628                     }
>  629                 }
>  630                 return start + 1;
>  631             }
>  632             return fence;
>  633         }
> 
>                   if (value[start++] == '\r') {
>                       if (start < fence && value[start] == '\n') {
>                           start++;  // return start + 1;
>                       }
>                  }
>                  return start;
> 
> not sure if it's really better or not ?
> 



More information about the core-libs-dev mailing list