java.lang.String#contentEquals(CharSequence) suboptimal? (original) (raw)

Ulf Zibis Ulf.Zibis at gmx.de
Mon Jan 4 16:55:20 UTC 2010


I agree, this would be a short cut in case of cs is not a String. In case of cs is a String, user likely would have used the standard equals() method to avoid the double check by instanceof. In case of HotSpot compilation AND inlining, there should be no difference.

-Ulf

Am 04.01.2010 16:15, Alexander Veit schrieb:

Hi,

it seems that if (cs.equals(this)) return true; should be replaced with if (cs instanceof String) return cs.equals(this); or completely left out. Does anyone agree?



More information about the core-libs-dev mailing list