lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "jian chen" <chenjian1...@gmail.com>
Subject Re: this == that
Date Mon, 01 May 2006 21:48:20 GMT
I am wondering if interning Strings will be really that critical for
performance. The biggest bottle neck is still disk. So, maybe we can use
String.equals(...) instead of ==.

Jian

On 5/1/06, DM Smith <dmsmith555@gmail.com> wrote:
>
> 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
> optimization.
>
> 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: java-dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-dev-help@lucene.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message