alexander.veit at gmx.net
Mon Jan 4 17:08:04 UTC 2010
> String.equals already performs that instanceof comparison,
> and is one of the first to be inlined by the hotspot. What I
> would do is to turn it... "this.equals(cs)" instead of
That's true, but given cs is a String with length equal to this, cs.equals(this) nevertheless may return false, and
will not return. The remaining code performs the comparison a second time in this case.
> Anyway, does anyone know if the
> contentEquals method is actually used out there? (at least it
> isn't inside the JDK source code).
I use it ;-) It is useful to prevent from duplicate memory allocation in quite some cases.
More information about the core-libs-dev