RFR 8214971 : Replace use of string.equals("") with isEmpty()
roger.riggs at oracle.com
Thu Dec 6 21:51:32 UTC 2018
Yes, it is likely that the compiler gets to the same optimization.
But we save a little bit too by not making the compiler work so hard.
And it helps during startup before the compiler kicks in.
IntelliJ did the hard work and a full CI build/test is in progress.
And isEmpty reads better.
On 12/6/18 3:27 PM, Jim Laskey wrote:
> 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?
> — 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:
>> Thanks, Roger
More information about the core-libs-dev