ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1045116 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/util/VectorSet.java
Date Mon, 13 Dec 2010 13:44:48 GMT
Author: bodewig
Date: Mon Dec 13 13:44:48 2010
New Revision: 1045116

URL: http://svn.apache.org/viewvc?rev=1045116&view=rev
Log:
improve performance of VectorSet#add - PR 50200

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/util/VectorSet.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1045116&r1=1045115&r2=1045116&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Mon Dec 13 13:44:48 2010
@@ -286,6 +286,10 @@ Other changes:
    compile to .class files).
    Bugzilla Report 48829.
 
+ * The performance of VectorSet#add(Object) has been improved which
+   should also benefit any operation that scans directories in Ant.
+   Bugzilla Report 50200.
+
 Changes from Ant 1.8.0 TO Ant 1.8.1 
 ===================================
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/VectorSet.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/VectorSet.java?rev=1045116&r1=1045115&r2=1045116&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/VectorSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/VectorSet.java Mon Dec 13 13:44:48 2010
@@ -76,13 +76,13 @@ public final class VectorSet extends Vec
         // Vector.add seems to delegate to insertElementAt, but this
         // is not documented so we may better implement it ourselves
         if (set.add(o)) {
-            ensureCapacity(size() + 1);
-            Object[] elems = new Object[elementData.length];
-            System.arraycopy(elementData, 0, elems, 0, index);
-            elems[index] = o;
-            System.arraycopy(elementData, index, elems, index + 1,
-                             size() - index);
-            elementData = elems;
+            int count = size();
+            ensureCapacity(count + 1);
+            if (index != count) {
+                System.arraycopy(elementData, index, elementData, index + 1,
+                                 count - index);
+            }
+            elementData[index] = o;
             elementCount++;
         }
     }



Mime
View raw message