[jdom-interest] Reference comparisons in SAXHandler.startElem ent

GB/DEV - Philip Nelson philip.nelson at omniresources.com
Tue Mar 13 13:23:56 PST 2001

> 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)

the == versions were took 8491 and 10213 respectively.  These numbers are
JInsight numbers so I don't know exactly what the units are.  I have noticed
String.equals calls in Element.java taking up very large portions of the
overall processing time to build an Element in memory and so I have been
watching for these as I test.

More information about the jdom-interest mailing list