lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tatu Saloranta <cowtownco...@yahoo.com>
Subject Re: this == that
Date Sun, 30 Apr 2006 02:48:25 GMT
--- karl wettin <kalle@snigel.net> wrote:

> The code is filled with string equality code using
> == rather than  
> equals(). I honestly don't think it saves a single
> clock tick as the  
> JIT takes care of it when the first line of code in
> the equals method  
> is if (this == that) return true;

In case where (this == that) is true, this may well be
correct, but:

> 
> Please correct me if I'm wrong.

... you are then assuming 100% match rate: if so this
might be true. But in (this != that) case difference
will be more significant; after identity comparison
String lengths are compared, and if those match, then
char-by-char comparison.
So it probably does not make sense to de-optimize code
in this way.

-+ Tatu +-


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message