Typical implementation of String.equals() (like most hashable objects) is:

      Compare ==, in case they're the same object.
      Compare cached hashcodes; if they don't match they aren't the same
value.
      Then compare content in case two values just happened to have the
same hash.

Using ==, when you know the strings are interned or otherwise unique
values, does potentially save some cycles for the call-and-return. A good
JIT compiler *may* be able to give close to the same performance by doing a
bit of slightly-intelligent inlining... but if you're in an inner loop, the
hand-optimization may be fully justified. Especially if performance
analysers are telling you it really does make a difference.

But it may be worth tossing a comment or two into the code to reassure
folks that == really was intended.

______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to