This removes 2 explicit null checks in Vector. The Mauve test that I'll commit right after this shows that the RI allows null arguments when the Vector is empty. In the other case we throw an NPE implicitly anyway.

2006-08-15  Roman Kennke  <[EMAIL PROTECTED]>

        * java/util/Vector.java
        (removeAll): Don't explicitly null-check here. The RI allows
        null arguments when Vector is empty. In other cases we
        implicitly throw an NPE.
        (retainAll): Don't explicitly null-check here. The RI allows
        null arguments when Vector is empty. In other cases we
        implicitly throw an NPE.

/Roman
Index: java/util/Vector.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Vector.java,v
retrieving revision 1.27
diff -u -1 -2 -r1.27 Vector.java
--- java/util/Vector.java	26 Jul 2006 06:48:47 -0000	1.27
+++ java/util/Vector.java	15 Aug 2006 09:42:46 -0000
@@ -711,27 +711,24 @@
   }
 
   /**
    * Remove from this vector all elements contained in the given collection.
    *
    * @param c the collection to filter out
    * @return true if this vector changed
    * @throws NullPointerException if c is null
    * @since 1.2
    */
   public synchronized boolean removeAll(Collection c)
   {
-    if (c == null)
-      throw new NullPointerException();
-
     int i;
     int j;
     for (i = 0; i < elementCount; i++)
       if (c.contains(elementData[i]))
         break;
     if (i == elementCount)
       return false;
 
     modCount++;
     for (j = i++; i < elementCount; i++)
       if (! c.contains(elementData[i]))
         elementData[j++] = elementData[i];
@@ -740,27 +737,24 @@
   }
 
   /**
    * Retain in this vector only the elements contained in the given collection.
    *
    * @param c the collection to filter by
    * @return true if this vector changed
    * @throws NullPointerException if c is null
    * @since 1.2
    */
   public synchronized boolean retainAll(Collection c)
   {
-    if (c == null)
-      throw new NullPointerException();
-
     int i;
     int j;
     for (i = 0; i < elementCount; i++)
       if (! c.contains(elementData[i]))
         break;
     if (i == elementCount)
       return false;
 
     modCount++;
     for (j = i++; i < elementCount; i++)
       if (c.contains(elementData[i]))
         elementData[j++] = elementData[i];

Reply via email to