Return-Path: Delivered-To: apmail-incubator-felix-commits-archive@www.apache.org Received: (qmail 13389 invoked from network); 11 Jul 2006 15:35:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Jul 2006 15:35:25 -0000 Received: (qmail 44556 invoked by uid 500); 11 Jul 2006 15:35:25 -0000 Delivered-To: apmail-incubator-felix-commits-archive@incubator.apache.org Received: (qmail 44533 invoked by uid 500); 11 Jul 2006 15:35:24 -0000 Mailing-List: contact felix-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: felix-dev@incubator.apache.org Delivered-To: mailing list felix-commits@incubator.apache.org Received: (qmail 44518 invoked by uid 99); 11 Jul 2006 15:35:24 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Jul 2006 08:35:24 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Jul 2006 08:35:24 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 666851A981C; Tue, 11 Jul 2006 08:35:00 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r420900 - /incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java Date: Tue, 11 Jul 2006 15:35:00 -0000 To: felix-commits@incubator.apache.org From: rickhall@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060711153500.666851A981C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: rickhall Date: Tue Jul 11 08:34:59 2006 New Revision: 420900 URL: http://svn.apache.org/viewvc?rev=420900&view=rev Log: Improved array shrinking algorithm. Modified: incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java Modified: incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java URL: http://svn.apache.org/viewvc/incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java?rev=420900&r1=420899&r2=420900&view=diff ============================================================================== --- incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java (original) +++ incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java Tue Jul 11 08:34:59 2006 @@ -1549,30 +1549,25 @@ return m_emptyModules; } - int count = 0; + // Move all non-null values to one end of the array. + int lower = 0; for (int i = 0; i < modules.length; i++) { - if (modules[i] == null) + if (modules[i] != null) { - count++; + modules[lower++] = modules[i]; } } - if (count > 0) + if (lower == 0) { - IModule[] newModules = new IModule[modules.length - count]; - count = 0; - for (int i = 0; i < modules.length; i++) - { - if (modules[i] != null) - { - newModules[count++] = modules[i]; - } - } - modules = newModules; + return m_emptyModules; } - return modules; + // Copy non-null values into a new array and return. + IModule[] newModules = new IModule[lower]; + System.arraycopy(modules, 0, newModules, 0, lower); + return newModules; } //