ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 50200] VectorSet kills the performance of DirectoryScanner
Date Mon, 13 Dec 2010 13:19:27 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=50200

--- Comment #2 from Stefan Bodewig <bodewig@apache.org> 2010-12-13 08:19:23 EST ---
or better

Index: src/main/org/apache/tools/ant/util/VectorSet.java
===================================================================
--- src/main/org/apache/tools/ant/util/VectorSet.java   (revision 1045104)
+++ src/main/org/apache/tools/ant/util/VectorSet.java   (working copy)
@@ -76,13 +76,13 @@
         // 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++;
         }
     }

which I'm going to commit to trunk shortly.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Mime
View raw message