diff --git a/WHATSNEW b/WHATSNEW index 50a824a1e..383583dfe 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -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 =================================== diff --git a/src/main/org/apache/tools/ant/util/VectorSet.java b/src/main/org/apache/tools/ant/util/VectorSet.java index 235027263..78c0f75d1 100644 --- a/src/main/org/apache/tools/ant/util/VectorSet.java +++ b/src/main/org/apache/tools/ant/util/VectorSet.java @@ -76,13 +76,13 @@ public final class VectorSet extends Vector { // 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++; } }