RFR 8214971 : Replace use of string.equals("") with isEmpty()

Jim Laskey james.laskey at oracle.com
Thu Dec 6 20:27:28 UTC 2018


I assume you automated this change, might be worthwhile to automate a verification (compare the -+ pairs.) Eyeballing the patch it seems complete, one comment changed as well.

Question: Is it probably that vm optimizes .equals(“”) to .isEmpty() and there is no net win, ie., more of an esthetic clean up than for performance?

Cheers,

— Jim



> On Dec 6, 2018, at 4:04 PM, Roger Riggs <Roger.Riggs at oracle.com> wrote:
> 
> Please review changing string.equals("") to string.isEmpty().
> isEmpty is preferred, performs better and is easier to optimize.
> 
> The change is a literal substitution in all files and only in these modules:
> 
>   java.base
>   java.logging
>   java.management
>   java.management.rmi
>   java.naming
>   java.net.http
>   java.prefs
>   java.rmi
>   java.scripting
>   java.sql
>   java.sql.rowset
>   java.xml
>   jdk.jartool
>   jdk.javadoc
>   jdk.jcmd
>   jdk.jconsole
>   jdk.management.agent
>   jdk.naming.dns
>   jdk.rmic
> 
> 
> Webrev:
> http://cr.openjdk.java.net/~rriggs/webrev-string-isempty-8214971-1/
> 
> Issue:
>   https://bugs.openjdk.java.net/browse/JDK-8214971
> 
> Thanks, Roger



More information about the core-libs-dev mailing list