felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
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 GMT
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;
     }
 
     //



Mime
View raw message