[jdom-interest] Reference comparisons in SAXHandler.startElement

Jason Hunter jhunter at collab.net
Tue Mar 13 10:36:11 PST 2001


"Rosen, Alex" wrote:
> 
> The first thing that String.equals() does is to see if the two strings are ==
> and return true if so. So why not just use .equals()? The cost of the extra
> method call will certainly be lost in the noise.

Your proposal would allow a comparison to "succeed fast" but "fail
slowly".  That's only good if you expect success.  In SAX building it's
expected the names won't match, and thus it's faster to have the ==
check so you can fail quickly also.

-jh-



More information about the jdom-interest mailing list