what-the-bank/sources/com/google/firebase/crashlytics/internal/stacktrace/RemoveRepeatsStrategy.java

69 lines
2.6 KiB
Java

package com.google.firebase.crashlytics.internal.stacktrace;
import java.util.HashMap;
/* loaded from: classes2.dex */
public class RemoveRepeatsStrategy implements StackTraceTrimmingStrategy {
private final int maxRepetitions;
public RemoveRepeatsStrategy() {
this(1);
}
public RemoveRepeatsStrategy(int i) {
this.maxRepetitions = i;
}
@Override // com.google.firebase.crashlytics.internal.stacktrace.StackTraceTrimmingStrategy
public StackTraceElement[] getTrimmedStackTrace(StackTraceElement[] stackTraceElementArr) {
StackTraceElement[] trimRepeats = trimRepeats(stackTraceElementArr, this.maxRepetitions);
return trimRepeats.length < stackTraceElementArr.length ? trimRepeats : stackTraceElementArr;
}
private static StackTraceElement[] trimRepeats(StackTraceElement[] stackTraceElementArr, int i) {
int i2;
HashMap hashMap = new HashMap();
StackTraceElement[] stackTraceElementArr2 = new StackTraceElement[stackTraceElementArr.length];
int i3 = 0;
int i4 = 0;
int i5 = 1;
while (i3 < stackTraceElementArr.length) {
StackTraceElement stackTraceElement = stackTraceElementArr[i3];
Integer num = (Integer) hashMap.get(stackTraceElement);
if (num == null || !isRepeatingSequence(stackTraceElementArr, num.intValue(), i3)) {
stackTraceElementArr2[i4] = stackTraceElementArr[i3];
i4++;
i5 = 1;
i2 = i3;
} else {
int intValue = i3 - num.intValue();
if (i5 < i) {
System.arraycopy(stackTraceElementArr, i3, stackTraceElementArr2, i4, intValue);
i4 += intValue;
i5++;
}
i2 = (intValue - 1) + i3;
}
hashMap.put(stackTraceElement, Integer.valueOf(i3));
i3 = i2 + 1;
}
StackTraceElement[] stackTraceElementArr3 = new StackTraceElement[i4];
System.arraycopy(stackTraceElementArr2, 0, stackTraceElementArr3, 0, i4);
return stackTraceElementArr3;
}
/* JADX WARN: Multi-variable type inference failed */
private static boolean isRepeatingSequence(StackTraceElement[] stackTraceElementArr, int i, int i2) {
int i3 = i2 - i;
if (i2 + i3 > stackTraceElementArr.length) {
return false;
}
for (int i4 = 0; i4 < i3; i4++) {
if (!stackTraceElementArr[i + i4].equals(stackTraceElementArr[i2 + i4])) {
return false;
}
}
return true;
}
}