You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2012/09/29 01:30:32 UTC

svn commit: r1391695 - in /commons/proper/lang/trunk/src: changes/changes.xml main/java/org/apache/commons/lang3/ArrayUtils.java

Author: sebb
Date: Fri Sep 28 23:30:31 2012
New Revision: 1391695

URL: http://svn.apache.org/viewvc?rev=1391695&view=rev
Log:
LANG-838 ArrayUtils removeElements methods clone temporary index arrays unnecessarily

Modified:
    commons/proper/lang/trunk/src/changes/changes.xml
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java

Modified: commons/proper/lang/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/changes/changes.xml?rev=1391695&r1=1391694&r2=1391695&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/changes/changes.xml (original)
+++ commons/proper/lang/trunk/src/changes/changes.xml Fri Sep 28 23:30:31 2012
@@ -22,6 +22,7 @@
   <body>
 
   <release version="3.2" date="TBA" description="Next release">
+    <action issue="LANG-838" type="update">ArrayUtils removeElements methods clone temporary index arrays unnecessarily</action>
     <action issue="LANG-832" type="fix">FastDateParser does not handle unterminated quotes correctly</action>
     <action issue="LANG-831" type="fix">FastDateParser does not handle white-space properly</action>
     <action issue="LANG-830" type="fix">FastDateParser could use \Q \E to quote regexes</action>

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java?rev=1391695&r1=1391694&r2=1391695&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/ArrayUtils.java Fri Sep 28 23:30:31 2012
@@ -5019,7 +5019,9 @@ public class ArrayUtils {
                 toRemove.add(found++);
             }
         }
-        return removeAll(array, extractIndices(toRemove));
+        @SuppressWarnings("unchecked") // removeAll() always creates an array of the same type as its input
+        T[] result = (T[]) removeAll((Object)array, extractIndices(toRemove));
+        return result;
     }
 
     /**
@@ -5108,7 +5110,7 @@ public class ArrayUtils {
                 toRemove.add(found++);
             }
         }
-        return removeAll(array, extractIndices(toRemove));
+        return (byte[]) removeAll((Object)array, extractIndices(toRemove));
     }
 
     /**
@@ -5197,7 +5199,7 @@ public class ArrayUtils {
                 toRemove.add(found++);
             }
         }
-        return removeAll(array, extractIndices(toRemove));
+        return (short[]) removeAll((Object)array, extractIndices(toRemove));
     }
 
     /**
@@ -5286,7 +5288,7 @@ public class ArrayUtils {
                 toRemove.add(found++);
             }
         }
-        return removeAll(array, extractIndices(toRemove));
+        return (int[]) removeAll((Object)array, extractIndices(toRemove));
     }
 
     /**
@@ -5375,7 +5377,7 @@ public class ArrayUtils {
                 toRemove.add(found++);
             }
         }
-        return removeAll(array, extractIndices(toRemove));
+        return (char[]) removeAll((Object)array, extractIndices(toRemove));
     }
 
     /**
@@ -5464,7 +5466,7 @@ public class ArrayUtils {
                 toRemove.add(found++);
             }
         }
-        return removeAll(array, extractIndices(toRemove));
+        return (long[]) removeAll((Object)array, extractIndices(toRemove));
     }
 
     /**
@@ -5553,7 +5555,7 @@ public class ArrayUtils {
                 toRemove.add(found++);
             }
         }
-        return removeAll(array, extractIndices(toRemove));
+        return (float[]) removeAll((Object)array, extractIndices(toRemove));
     }
 
     /**
@@ -5642,7 +5644,7 @@ public class ArrayUtils {
                 toRemove.add(found++);
             }
         }
-        return removeAll(array, extractIndices(toRemove));
+        return (double[]) removeAll((Object)array, extractIndices(toRemove));
     }
 
     /**
@@ -5727,7 +5729,7 @@ public class ArrayUtils {
                 toRemove.add(found++);
             }
         }
-        return removeAll(array, extractIndices(toRemove));
+        return (boolean[]) removeAll((Object)array, extractIndices(toRemove));
     }
 
     /**