RFR: 8274168: Avoid String.compareTo == 0 to check String equality in java.management
Andrey Turbanov
github.com+741251+turbanoff at openjdk.java.net
Wed Sep 22 21:36:56 UTC 2021
On Wed, 22 Sep 2021 20:58:47 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:
>> Cleanup places, where String.compareTo is used to check String's equality.
>> Instead String.equals or switch expression could be used. They are faster and code is cleaner.
>
> src/java.management/share/classes/javax/management/BinaryRelQueryExp.java line 180:
>
>> 178: return sval1.compareTo(sval2) <= 0;
>> 179: case Query.EQ:
>> 180: return sval1.equals(sval2);
>
> I'm not so sure I agree this is better. Using `compareTo` keeps it consistent with the surrounding code.
But it's now consistent with Query operator: **EQ**uals
-------------
PR: https://git.openjdk.java.net/jdk/pull/5640
More information about the serviceability-dev
mailing list