RFR 8214971 : Replace use of string.equals("") with isEmpty()
claes.redestad at oracle.com
Thu Dec 6 22:42:00 UTC 2018
I filed this bug after seeing it in startup profiles, where isEmpty()
avoids an instanceof and four(!) method calls, so getting rid of a few
of these has a measurable impact on startup. It seemed prudent to just
replace it all while we're at it.
C2 should be able to optimize equals("") to the equivalent of isEmpty()
for hot cases, of course, but those JIT threads are probably better
spent optimizing other things. :-)
On 2018-12-06 21:27, 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