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

Wesley Biggs wbiggs at elite.com
Wed Mar 14 10:55:53 PST 2001


Philip,

== is *ALWAYS* going to be faster than .equals(), because you don't have to
look up a virtual method, switch context for it, etc. The == operator is an
atomic JVM opcode.

I also think that because the time spent context switching is probably the
major piece of calling .equals(), a forced call to .intern() is going to
take almost as long.  It would definitely be nice if we could assume the
parser has intern()ed for us.

One more thing: sorry if this sounds picky, but please avoid posting
JavaSoft source to the list.  It's anathema to anyone wanting to participate
in a cleanroom implementation of any Java APIs.

Wes


-----Original Message-----
From: GB/DEV - Philip Nelson [mailto:philip.nelson at omniresources.com]

I can't trace to the lines in the equals method but perhaps the thing that
takes the time is the cast.  It looks like if the strings are interned, it
won't make any difference whether we use == or .equals



More information about the jdom-interest mailing list