You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2014/01/02 16:29:14 UTC

svn commit: r1554830 - in /ant/core/trunk/src/main/org/apache/tools/ant/util: IdentityStack.java VectorSet.java

Author: bodewig
Date: Thu Jan  2 15:29:13 2014
New Revision: 1554830

URL: http://svn.apache.org/r1554830
Log:
two more optimizations by Adrian Nistor I overlooked

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

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/IdentityStack.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/IdentityStack.java?rev=1554830&r1=1554829&r2=1554830&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/IdentityStack.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/IdentityStack.java Thu Jan  2 15:29:13 2014
@@ -113,6 +113,13 @@ public class IdentityStack<E> extends St
         return super.removeAll(c);
     }
 
+    public synchronized boolean retainAll(Collection c) {
+        if (!(c instanceof Set)) {
+            c = new HashSet(c);
+        }
+        return super.retainAll(c);
+    }
+
     public synchronized boolean containsAll(Collection<?> c) {
         IdentityHashMap map = new IdentityHashMap();
         for (Object e : this) {

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=1554830&r1=1554829&r2=1554830&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 Thu Jan  2 15:29:13 2014
@@ -106,14 +106,26 @@ public final class VectorSet<E> extends 
      * if any of them are already contained in the collection.
      */
     public synchronized boolean addAll(int index, Collection<? extends E> c) {
-        boolean changed = false;
+        LinkedList toAdd = new LinkedList();
         for (E e : c) {
-            if (!set.contains(e)) {
-                doAdd(index++, e);
-                changed = true;
+            if (set.add(e)) {
+                toAdd.add(e);
             }
         }
-        return changed;
+        if (toAdd.isEmpty()) {
+            return false;
+        }
+        int count = size();
+        ensureCapacity(count + toAdd.size());
+        if (index != count) {
+            System.arraycopy(elementData, index, elementData, index + toAdd.size(),
+                             count - index);
+        }
+        for (Object o : toAdd) {
+            elementData[index++] = o;
+        }
+        elementCount += toAdd.size();
+        return true;
     }
 
     public synchronized void clear() {
@@ -227,4 +239,4 @@ public final class VectorSet<E> extends 
         set(index, o);
     }
 
-}
\ No newline at end of file
+}