RFR - JDK-8223775 String::stripIndent (Preview)

Jim Laskey james.laskey at oracle.com
Tue May 21 18:37:48 UTC 2019



> On May 21, 2019, at 3:27 PM, Vicente Romero <vicente.romero at oracle.com> wrote:
> 
> Hi Jim,
> 
> Some minor comments:
> 
> - the javadoc for String::stripIndent needs some formating. There is a solitary "counted. The"

Looking for a code review at this point. Will get to API soon.

> - at method String::stripIndent, you can bail out and do nothing if outdent==0

Not really, we still need to stripTrailing, but I could optimize that case.

> - suggestion: method String::outdent could return a Map<Integer, Integer> to indicate the first index of a non-whitespace per line. I concede that you probably won't be able to use a lambda at the end but you will avoid invoking String::indexOfNonWhitespace per line again at String::stripIndent

Considered  using an int array but it's a time vs memory situation. Cost of managing the map would outweigh the cost of recomputation. The scan is pretty quick.

> 
> Thanks,
> Vicente

Thank you.


> 
> On 5/21/19 10:56 AM, Jim Laskey wrote:
>> Please do a code review of the new String::stripIndent instance method. This instance method is being introduced to support JEP-355: Text Blocks, by removing incidental indentation from the text block content. The algorithm used is defined in the JEP and also described in the JBS entry.
>> 
>> Thank you.
>> 
>> -- Jim
>> 
>> webrev: http://cr.openjdk.java.net/~jlaskey/8223775/webrev-01 <http://cr.openjdk.java.net/~jlaskey/8223775/webrev-01>
>> jbs: https://bugs.openjdk.java.net/browse/JDK-8223775 <https://bugs.openjdk.java.net/browse/JDK-8223775>
>> csr: https://bugs.openjdk.java.net/browse/JDK-8223776 <https://bugs.openjdk.java.net/browse/JDK-8223776>
>> jep: https://bugs.openjdk.java.net/browse/JDK-8222530 <https://bugs.openjdk.java.net/browse/JDK-8222530>
>> 
>> 
> 



More information about the compiler-dev mailing list