[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-awt-dev
Subject:    Re: <AWT Dev> RFR: 8252999: replace all String.equals("") usages with String.isEmpty()
From:       Sergey Bylokhov <serb () openjdk ! java ! net>
Date:       2020-09-10 8:52:29
Message-ID: aEysicdznhelazv6VnUAtKnv9CGn-Mrkuk5ym3GQXJU=.1187719b-9d05-4038-955a-698b13f1a22e () github ! com
[Download RAW message or body]

On Sun, 6 Sep 2020 13:57:19 GMT, Dmitriy Dumanskiy <github.com+1536494+doom369@openjdk.org> wrote:

> **isEmpty** is faster + has less byte code + easier to read. Benchmarks could be found
>   [here](https://medium.com/javarevisited/micro-optimizations-in-java-string-equals-22be19fd8416).

src/demo/share/java2d/J2DBench/src/j2dbench/tests/iio/InputImageTests.java line 187:

> 185:             String format = spi.getFormatNames()[0].toLowerCase();
> 186:             String suffix = spi.getFileSuffixes()[0].toLowerCase();
> 187:             if (suffix == null || suffix.equals("")) {

This file intentionally maintains compatibility to jdk1.4, so equals("") should be used.

src/demo/share/java2d/J2DBench/src/j2dbench/tests/iio/OutputImageTests.java line 146:

> 144:             String format = spi.getFormatNames()[0].toLowerCase();
> 145:             String suffix = spi.getFileSuffixes()[0].toLowerCase();
> 146:             if (suffix == null || suffix.equals("")) {

This file intentionally maintains compatibility to jdk1.4, so equals("") should be used.

-------------

PR: https://git.openjdk.java.net/jdk/pull/29
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic