RFR: 8215281: Use String.isEmpty() where applicable in java.base

Daniel Fuchs daniel.fuchs at oracle.com
Wed Dec 12 16:54:29 UTC 2018


Hi Claes,

It might read even better if things like:

+        resultString = !specarg.isEmpty() ? specarg.intern(): opt;

were changed into:

+        resultString = specarg.isEmpty() ? opt : specarg.intern();

best regards,

-- daniel

On 12/12/2018 16:53, Claes Redestad wrote:
> Hi,
> 
> please review this patch to use String.isEmpty when applicable:
> 
> Webrev: http://cr.openjdk.java.net/~redestad/8215281/jdk.00/
> Bug: https://bugs.openjdk.java.net/browse/JDK-8215281
> 
> Why?
> - It reads better :-)
> - Better startup/warmup due fewer method invocations
> - Better peak performance: String.isEmpty is ~1.2x faster than
>    String.length
> 
> Most changes are simple search and replace, but I took the liberty to
> clean out some dead/pointless uses and improve formatting in places due
> the shorter expression length.
> 
> Instances of "".equals(string) were only changed when it was immediately
> obvious that string is not null, e.g., due a preceding null check.
> 
> Thanks!
> 
> /Claes



More information about the security-dev mailing list