fix: rollback ArrayTools because less is more

This commit is contained in:
punchready 2021-06-03 23:15:29 +02:00
parent 257a3e2022
commit d4e0ed23bc

View File

@ -1,7 +1,6 @@
package uulm.teamname.marvelous.gamelibrary; package uulm.teamname.marvelous.gamelibrary;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
/** Provides various tools for Arrays. */ /** Provides various tools for Arrays. */
public class ArrayTools { public class ArrayTools {
@ -14,7 +13,12 @@ public class ArrayTools {
*/ */
public static <E> ArrayList<E> toArrayList(E[] a) { public static <E> ArrayList<E> toArrayList(E[] a) {
ArrayList<E> l = new ArrayList<>(a.length); ArrayList<E> l = new ArrayList<>(a.length);
l.addAll(Arrays.asList(a)); //faster than Collections.addAll(l, a); because it doesn't do any boolean operations
//noinspection ManualArrayToCollectionCopy
for(E e: a) {
//noinspection UseBulkOperation
l.add(e);
}
return l; return l;
} }
} }