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

Alan Bateman Alan.Bateman at oracle.com
Wed Dec 12 16:56:17 UTC 2018


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.
In Checks.java, the parameter change from CharSequence to String means 
that "cs" needs to be renamed.

-Alan.



More information about the security-dev mailing list