[jdom-interest] Reference comparisons in SAXHandler.startElement

Louis Tribble louis.tribble at metamata.com
Tue Mar 13 14:52:29 PST 2001


GB/DEV - Philip Nelson wrote:
> 
> > Good point. On the other hand, when the strings don't match,
> > String.equals() is
> > usually going to discover this by examining just the first
> > character or two (in
> > the most common cases). Not as fast as ==, but it won't have
> > to check every
> > single character. It just doesn't seem like this optimization
> > is worth the bugs
> > it'll introduce.
> 
> FWIW, this may be true but on a quick test of 10000 string.equals vs 10000
> string ==, the == is a tiny fraction of the time.  Also, .equals for
> "yyyyyy" and "yyyyyy" (149616) took approximately as long as "yyyyy" to
> "xyyyy" (184641)

I believe equals() also short circuits if the lengths are unequal: to
what extent does the test data compare different lengths (and does it
make much difference?).

Louis
-- 

<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Louis Tribble                                         louis at metamata.com
Metamata, Inc.                                   http://www.metamata.com
Tools for serious Java developers.                       +1 510 796 0915
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>



More information about the jdom-interest mailing list