You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
3.6 KiB

package p039m1;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
/* renamed from: m1.d */
/* loaded from: classes.dex */
public final class C1467d {
/* renamed from: a */
public static final Object[] f3222a = new Object[0];
/* renamed from: a */
public static final Object[] m1298a(Collection<?> collection) {
C1470g.m1292e(collection, "collection");
int size = collection.size();
if (size != 0) {
Iterator<?> it = collection.iterator();
if (it.hasNext()) {
Object[] objArr = new Object[size];
int i = 0;
while (true) {
int i2 = i + 1;
objArr[i] = it.next();
if (i2 >= objArr.length) {
if (!it.hasNext()) {
return objArr;
}
int i3 = ((i2 * 3) + 1) >>> 1;
if (i3 <= i2) {
i3 = 2147483645;
if (i2 >= 2147483645) {
throw new OutOfMemoryError();
}
}
objArr = Arrays.copyOf(objArr, i3);
C1470g.m1293d(objArr, "copyOf(result, newSize)");
} else if (!it.hasNext()) {
Object[] copyOf = Arrays.copyOf(objArr, i2);
C1470g.m1293d(copyOf, "copyOf(result, size)");
return copyOf;
}
i = i2;
}
}
}
return f3222a;
}
/* renamed from: b */
public static final Object[] m1297b(Collection<?> collection, Object[] objArr) {
Object[] objArr2;
C1470g.m1292e(collection, "collection");
objArr.getClass();
int size = collection.size();
int i = 0;
if (size == 0) {
if (objArr.length > 0) {
objArr[0] = null;
return objArr;
}
return objArr;
}
Iterator<?> it = collection.iterator();
if (!it.hasNext()) {
if (objArr.length > 0) {
objArr[0] = null;
return objArr;
}
return objArr;
}
if (size <= objArr.length) {
objArr2 = objArr;
} else {
Object newInstance = Array.newInstance(objArr.getClass().getComponentType(), size);
C1470g.m1294c(newInstance, "null cannot be cast to non-null type kotlin.Array<kotlin.Any?>");
objArr2 = (Object[]) newInstance;
}
while (true) {
int i2 = i + 1;
objArr2[i] = it.next();
if (i2 >= objArr2.length) {
if (!it.hasNext()) {
return objArr2;
}
int i3 = ((i2 * 3) + 1) >>> 1;
if (i3 <= i2) {
i3 = 2147483645;
if (i2 >= 2147483645) {
throw new OutOfMemoryError();
}
}
objArr2 = Arrays.copyOf(objArr2, i3);
C1470g.m1293d(objArr2, "copyOf(result, newSize)");
} else if (!it.hasNext()) {
if (objArr2 == objArr) {
objArr[i2] = null;
return objArr;
}
Object[] copyOf = Arrays.copyOf(objArr2, i2);
C1470g.m1293d(copyOf, "copyOf(result, size)");
return copyOf;
}
i = i2;
}
}
}