Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 39325 invoked from network); 20 Sep 2007 12:21:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Sep 2007 12:21:10 -0000 Received: (qmail 48121 invoked by uid 500); 20 Sep 2007 12:21:01 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 48104 invoked by uid 500); 20 Sep 2007 12:21:01 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 48095 invoked by uid 99); 20 Sep 2007 12:21:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Sep 2007 05:21:01 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Sep 2007 12:21:09 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E77381A9832; Thu, 20 Sep 2007 05:20:48 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r577715 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java Date: Thu, 20 Sep 2007 12:20:48 -0000 To: commits@harmony.apache.org From: tellison@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070920122048.E77381A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tellison Date: Thu Sep 20 05:20:48 2007 New Revision: 577715 URL: http://svn.apache.org/viewvc?rev=577715&view=rev Log: Revert r575658 (Optimization for Integer keys in HashMap) awaiting further analysis. Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java?rev=577715&r1=577714&r2=577715&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java (original) +++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java Thu Sep 20 05:20:48 2007 @@ -43,28 +43,18 @@ private static final int DEFAULT_SIZE = 16; static class Entry extends MapEntry { - final int storedKeyHash; + final int origKeyHash; Entry next; Entry(K theKey, int hash) { super(theKey, null); - if (theKey instanceof Integer) { - this.storedKeyHash = hash | 0x00000001; - } else { - this.storedKeyHash = hash & 0xFFFFFFFE; - } + this.origKeyHash = hash; } Entry(K theKey, V theValue) { super(theKey, theValue); - if (theKey == null) { - storedKeyHash = 0; - } else if (theKey instanceof Integer) { - storedKeyHash = theKey.hashCode() | 0x00000001; - } else { - storedKeyHash = theKey.hashCode() & 0xFFFFFFFE; - } + origKeyHash = (theKey == null ? 0 : theKey.hashCode()); } @Override @@ -261,16 +251,13 @@ } private static final int calculateCapacity(int x) { - if (x >= 1 << 30) { + if(x >= 1 << 30){ return 1 << 30; } - if (x == 0) { + if(x == 0){ return 16; } - if (x == 1) { - return 2; - } - x = x - 1; + x = x -1; x |= x >> 1; x |= x >> 2; x |= x >> 4; @@ -458,25 +445,16 @@ final Entry findNonNullKeyEntry(Object key, int index, int keyHash) { Entry m = elementData[index]; - if (key instanceof Integer) { - int storedKeyHash = keyHash | 0x00000001; - while (m != null && (m.storedKeyHash != storedKeyHash)) { - m = m.next; - } - } else { - int storedKeyHash = keyHash & 0xFFFFFFFE; - while (m != null && (m.storedKeyHash != storedKeyHash || !key.equals(m.key))) { - m = m.next; - } + while (m != null && (m.origKeyHash != keyHash || !key.equals(m.key))) { + m = m.next; } return m; } final Entry findNullKeyEntry() { Entry m = elementData[0]; - while (m != null && m.key != null) { + while (m != null && m.key != null) m = m.next; - } return m; } @@ -591,7 +569,7 @@ } Entry createHashedEntry(K key, int index, int hash) { - Entry entry = new Entry(key, hash); + Entry entry = new Entry(key,hash); entry.next = elementData[index]; elementData[index] = entry; return entry; @@ -631,8 +609,7 @@ for (int i = 0; i < elementData.length; i++) { Entry entry = elementData[i]; while (entry != null) { - int actualHash = (i & 0x00000001) | (entry.storedKeyHash & 0xFFFFFFFE); - int index = actualHash & (length - 1); + int index = entry.origKeyHash & (length - 1); Entry next = entry.next; entry.next = newData[index]; newData[index] = entry; @@ -669,22 +646,12 @@ Entry entry; Entry last = null; if (key != null) { - int keyHash = key.hashCode(); - index = keyHash & (elementData.length - 1); + int hash = key.hashCode(); + index = hash & (elementData.length - 1); entry = elementData[index]; - - if (key instanceof Integer) { - int storedKeyHash = keyHash | 0x00000001; - while (entry != null && (entry.storedKeyHash != storedKeyHash)) { - last = entry; - entry = entry.next; - } - } else { - int storedKeyHash = keyHash & 0xFFFFFFFE; - while (entry != null && (entry.storedKeyHash != storedKeyHash || !key.equals(entry.key))) { - last = entry; - entry = entry.next; - } + while (entry != null && !(entry.origKeyHash == hash && key.equals(entry.key))) { + last = entry; + entry = entry.next; } } else { entry = elementData[0];