Return-Path: Delivered-To: apmail-lucene-java-dev-archive@www.apache.org Received: (qmail 40192 invoked from network); 1 May 2006 18:02:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 May 2006 18:02:47 -0000 Received: (qmail 31992 invoked by uid 500); 1 May 2006 18:02:44 -0000 Delivered-To: apmail-lucene-java-dev-archive@lucene.apache.org Received: (qmail 31958 invoked by uid 500); 1 May 2006 18:02:44 -0000 Mailing-List: contact java-dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-dev@lucene.apache.org Received: (qmail 31941 invoked by uid 99); 1 May 2006 18:02:44 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 May 2006 11:02:44 -0700 X-ASF-Spam-Status: No, hits=1.4 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [206.190.53.29] (HELO smtp104.plus.mail.re2.yahoo.com) (206.190.53.29) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 01 May 2006 11:02:43 -0700 Received: (qmail 94143 invoked from network); 1 May 2006 18:02:21 -0000 Received: from unknown (HELO ?192.168.1.52?) (dmsmith555@67.39.27.222 with plain) by smtp104.plus.mail.re2.yahoo.com with SMTP; 1 May 2006 18:02:20 -0000 Message-ID: <44564D2B.7060303@gmail.com> Date: Mon, 01 May 2006 14:02:19 -0400 From: DM Smith User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) MIME-Version: 1.0 To: java-dev@lucene.apache.org Subject: Re: this == that References: <9B6D1255-6580-4DD8-9C83-D1C37B331F95@snigel.net> In-Reply-To: <9B6D1255-6580-4DD8-9C83-D1C37B331F95@snigel.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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