https://issues.apache.org/bugzilla/show_bug.cgi?id=50200

--- Comment #2 from Stefan Bodewig <[email protected]> 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.

Reply via email to