RFR 8214971 : Replace use of string.equals("") with isEmpty()
Roger Riggs
Roger.Riggs at oracle.com
Fri Dec 7 14:36:39 UTC 2018
Hi Hannes,
I'd take that up as a separate issue. [1]
A nice thing about the current patch is that the change is uniform and
easier to review.
It would also be good to look at a utility method that efficiently does
the combined check.
Thanks, Roger
[1] 8215014 <https://bugs.openjdk.java.net/browse/JDK-8215014>
On 12/07/2018 04:24 AM, Hannes Wallnöfer wrote:
> Hi Roger,
>
> There are quite a few occurrences of the reverse calling pattern "".equals(str) in core libs.
>
> This is a bit more tricky because it allows str to be null, but when used following a null/not-null check it could be replaced with isEmpty() as well.
>
> I wonder if these should be included in the patch?
>
> Hannes
>
>
>> Am 06.12.2018 um 21:04 schrieb Roger Riggs <Roger.Riggs at oracle.com>:
>>
>> 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