Browse Source

improve performance of VectorSet#add - PR 50200

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1045116 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 14 years ago
parent
commit
0b7abed55e
2 changed files with 11 additions and 7 deletions
  1. +4
    -0
      WHATSNEW
  2. +7
    -7
      src/main/org/apache/tools/ant/util/VectorSet.java

+ 4
- 0
WHATSNEW View File

@@ -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
===================================



+ 7
- 7
src/main/org/apache/tools/ant/util/VectorSet.java View File

@@ -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++;
}
}


Loading…
Cancel
Save