lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DM Smith <>
Subject Re: this == that
Date Mon, 01 May 2006 18:02:19 GMT
karl wettin 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;
If the strings are intern() then it should be a touch faster.
If the strings are not interned then I think it may be a premature 

IMHO, using intern to optimize space is a reasonable optimization, but 
using == to compare such strings is error prone as it is possible that 
the comparison is looking at strings that have not been interned.

Unless it object identity is what is being tested or intern is an 
invariant, I think it is dangerous. It is easy to forget to intern or to 
propagate the pattern via cut and paste to an inappropriate context.
> Please correct me if I'm wrong.
> I can commit to do the changes to the core code if it is considered 
> interesting.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message