reduce number of created arrays

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1147508 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Matthew Jason Benson 2011-07-17 00:43:55 +00:00
parent 4b047fc607
commit 0bfa9cbfb8
1 changed files with 17 additions and 9 deletions

View File

@ -5019,7 +5019,7 @@ public class ArrayUtils {
toRemove.add(found++); toRemove.add(found++);
} }
} }
return removeAll(array, toPrimitive(toRemove.toArray(new Integer[toRemove.size()]))); return removeAll(array, extractIndices(toRemove));
} }
/** /**
@ -5109,7 +5109,7 @@ public class ArrayUtils {
toRemove.add(found++); toRemove.add(found++);
} }
} }
return removeAll(array, toPrimitive(toRemove.toArray(new Integer[toRemove.size()]))); return removeAll(array, extractIndices(toRemove));
} }
/** /**
@ -5199,7 +5199,7 @@ public class ArrayUtils {
toRemove.add(found++); toRemove.add(found++);
} }
} }
return removeAll(array, toPrimitive(toRemove.toArray(new Integer[toRemove.size()]))); return removeAll(array, extractIndices(toRemove));
} }
/** /**
@ -5289,7 +5289,7 @@ public class ArrayUtils {
toRemove.add(found++); toRemove.add(found++);
} }
} }
return removeAll(array, toPrimitive(toRemove.toArray(new Integer[toRemove.size()]))); return removeAll(array, extractIndices(toRemove));
} }
/** /**
@ -5379,7 +5379,7 @@ public class ArrayUtils {
toRemove.add(found++); toRemove.add(found++);
} }
} }
return removeAll(array, toPrimitive(toRemove.toArray(new Integer[toRemove.size()]))); return removeAll(array, extractIndices(toRemove));
} }
/** /**
@ -5469,7 +5469,7 @@ public class ArrayUtils {
toRemove.add(found++); toRemove.add(found++);
} }
} }
return removeAll(array, toPrimitive(toRemove.toArray(new Integer[toRemove.size()]))); return removeAll(array, extractIndices(toRemove));
} }
/** /**
@ -5559,7 +5559,7 @@ public class ArrayUtils {
toRemove.add(found++); toRemove.add(found++);
} }
} }
return removeAll(array, toPrimitive(toRemove.toArray(new Integer[toRemove.size()]))); return removeAll(array, extractIndices(toRemove));
} }
/** /**
@ -5649,7 +5649,7 @@ public class ArrayUtils {
toRemove.add(found++); toRemove.add(found++);
} }
} }
return removeAll(array, toPrimitive(toRemove.toArray(new Integer[toRemove.size()]))); return removeAll(array, extractIndices(toRemove));
} }
/** /**
@ -5735,7 +5735,7 @@ public class ArrayUtils {
toRemove.add(found++); toRemove.add(found++);
} }
} }
return removeAll(array, toPrimitive(toRemove.toArray(new Integer[toRemove.size()]))); return removeAll(array, extractIndices(toRemove));
} }
/** /**
@ -5786,4 +5786,12 @@ public class ArrayUtils {
return result; return result;
} }
private static int[] extractIndices(HashSet<Integer> coll) {
int[] result = new int[coll.size()];
int i = 0;
for (Integer index : coll) {
result[i++] = index.intValue();
}
return result;
}
} }