Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 43599 invoked from network); 19 Sep 2006 11:16:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 Sep 2006 11:16:46 -0000 Received: (qmail 67254 invoked by uid 500); 19 Sep 2006 11:16:45 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 67193 invoked by uid 500); 19 Sep 2006 11:16:45 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 67182 invoked by uid 99); 19 Sep 2006 11:16:45 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Sep 2006 04:16:45 -0700 X-ASF-Spam-Status: No, hits=-9.8 required=5.0 tests=ALL_TRUSTED,NO_REAL_NAME Received: from ([140.211.166.113:64281] helo=eris.apache.org) by idunn.apache.osuosl.org (ecelerity 2.1 r(10620)) with ESMTP id 4D/81-26148-491DF054 for ; Tue, 19 Sep 2006 04:16:36 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 4FCD91A981A; Tue, 19 Sep 2006 04:16:34 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r447817 - /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java Date: Tue, 19 Sep 2006 11:16:34 -0000 To: harmony-commits@incubator.apache.org From: tellison@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20060919111634.4FCD91A981A@eris.apache.org> X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: tellison Date: Tue Sep 19 04:16:33 2006 New Revision: 447817 URL: http://svn.apache.org/viewvc?view=rev&rev=447817 Log: Apply patch HARMONY-1493 ([classlib][luni] java.util.HashMap:avoid expand backed element array more than once) Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java?view=diff&rev=447817&r1=447816&r2=447817 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java Tue Sep 19 04:16:33 2006 @@ -549,16 +549,18 @@ @Override public void putAll(Map map) { if (map.entrySet() != null) { + int capacity = elementCount + map.size(); + if (capacity > threshold) { + rehash(capacity); + } super.putAll(map); } } - void rehash() { - int length = elementData.length << 1; - if (length == 0) { - length = 1; - } - Entry[] newData = newElementArray(length); + void rehash(int capacity) { + int length = (capacity == 0 ? 1 : capacity << 1); + + Entry[] newData = newElementArray(length); for (int i = 0; i < elementData.length; i++) { Entry entry = elementData[i]; while (entry != null) { @@ -573,6 +575,10 @@ } elementData = newData; computeMaxSize(); + } + + void rehash() { + rehash(elementData.length); } /**