180 lines
6.4 KiB
Java
180 lines
6.4 KiB
Java
package androidx.collection;
|
|
|
|
import java.util.LinkedHashMap;
|
|
import java.util.Locale;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class LruCache<K, V> {
|
|
private final LinkedHashMap<K, V> a;
|
|
private int b;
|
|
private int c;
|
|
private int d;
|
|
private int e;
|
|
private int f;
|
|
private int g;
|
|
private int h;
|
|
|
|
public LruCache(int i) {
|
|
if (i <= 0) {
|
|
throw new IllegalArgumentException("maxSize <= 0");
|
|
}
|
|
this.c = i;
|
|
this.a = new LinkedHashMap<>(0, 0.75f, true);
|
|
}
|
|
|
|
private int c(K k, V v) {
|
|
int b = b(k, v);
|
|
if (b >= 0) {
|
|
return b;
|
|
}
|
|
throw new IllegalStateException("Negative size: " + k + "=" + v);
|
|
}
|
|
|
|
protected V a(K k) {
|
|
return null;
|
|
}
|
|
|
|
public final V a(K k, V v) {
|
|
V put;
|
|
if (k == null || v == null) {
|
|
throw new NullPointerException("key == null || value == null");
|
|
}
|
|
synchronized (this) {
|
|
this.d++;
|
|
this.b += c(k, v);
|
|
put = this.a.put(k, v);
|
|
if (put != null) {
|
|
this.b -= c(k, put);
|
|
}
|
|
}
|
|
if (put != null) {
|
|
a(false, k, put, v);
|
|
}
|
|
a(this.c);
|
|
return put;
|
|
}
|
|
|
|
protected void a(boolean z, K k, V v, V v2) {
|
|
}
|
|
|
|
protected int b(K k, V v) {
|
|
return 1;
|
|
}
|
|
|
|
public final V b(K k) {
|
|
V v;
|
|
if (k == null) {
|
|
throw new NullPointerException("key == null");
|
|
}
|
|
synchronized (this) {
|
|
V v2 = this.a.get(k);
|
|
if (v2 != null) {
|
|
this.g++;
|
|
return v2;
|
|
}
|
|
this.h++;
|
|
V a = a((LruCache<K, V>) k);
|
|
if (a == null) {
|
|
return null;
|
|
}
|
|
synchronized (this) {
|
|
this.e++;
|
|
v = (V) this.a.put(k, a);
|
|
if (v != null) {
|
|
this.a.put(k, v);
|
|
} else {
|
|
this.b += c(k, a);
|
|
}
|
|
}
|
|
if (v != null) {
|
|
a(false, k, a, v);
|
|
return v;
|
|
}
|
|
a(this.c);
|
|
return a;
|
|
}
|
|
}
|
|
|
|
public final synchronized String toString() {
|
|
int i;
|
|
i = this.g + this.h;
|
|
return String.format(Locale.US, "LruCache[maxSize=%d,hits=%d,misses=%d,hitRate=%d%%]", Integer.valueOf(this.c), Integer.valueOf(this.g), Integer.valueOf(this.h), Integer.valueOf(i != 0 ? (this.g * 100) / i : 0));
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:11:0x0070, code lost:
|
|
|
|
throw new java.lang.IllegalStateException(getClass().getName() + ".sizeOf() is reporting inconsistent results!");
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
|
*/
|
|
public void a(int r5) {
|
|
/*
|
|
r4 = this;
|
|
L0:
|
|
monitor-enter(r4)
|
|
int r0 = r4.b // Catch: java.lang.Throwable -> L71
|
|
if (r0 < 0) goto L52
|
|
java.util.LinkedHashMap<K, V> r0 = r4.a // Catch: java.lang.Throwable -> L71
|
|
boolean r0 = r0.isEmpty() // Catch: java.lang.Throwable -> L71
|
|
if (r0 == 0) goto L11
|
|
int r0 = r4.b // Catch: java.lang.Throwable -> L71
|
|
if (r0 != 0) goto L52
|
|
L11:
|
|
int r0 = r4.b // Catch: java.lang.Throwable -> L71
|
|
if (r0 <= r5) goto L50
|
|
java.util.LinkedHashMap<K, V> r0 = r4.a // Catch: java.lang.Throwable -> L71
|
|
boolean r0 = r0.isEmpty() // Catch: java.lang.Throwable -> L71
|
|
if (r0 == 0) goto L1e
|
|
goto L50
|
|
L1e:
|
|
java.util.LinkedHashMap<K, V> r0 = r4.a // Catch: java.lang.Throwable -> L71
|
|
java.util.Set r0 = r0.entrySet() // Catch: java.lang.Throwable -> L71
|
|
java.util.Iterator r0 = r0.iterator() // Catch: java.lang.Throwable -> L71
|
|
java.lang.Object r0 = r0.next() // Catch: java.lang.Throwable -> L71
|
|
java.util.Map$Entry r0 = (java.util.Map.Entry) r0 // Catch: java.lang.Throwable -> L71
|
|
java.lang.Object r1 = r0.getKey() // Catch: java.lang.Throwable -> L71
|
|
java.lang.Object r0 = r0.getValue() // Catch: java.lang.Throwable -> L71
|
|
java.util.LinkedHashMap<K, V> r2 = r4.a // Catch: java.lang.Throwable -> L71
|
|
r2.remove(r1) // Catch: java.lang.Throwable -> L71
|
|
int r2 = r4.b // Catch: java.lang.Throwable -> L71
|
|
int r3 = r4.c(r1, r0) // Catch: java.lang.Throwable -> L71
|
|
int r2 = r2 - r3
|
|
r4.b = r2 // Catch: java.lang.Throwable -> L71
|
|
int r2 = r4.f // Catch: java.lang.Throwable -> L71
|
|
r3 = 1
|
|
int r2 = r2 + r3
|
|
r4.f = r2 // Catch: java.lang.Throwable -> L71
|
|
monitor-exit(r4) // Catch: java.lang.Throwable -> L71
|
|
r2 = 0
|
|
r4.a(r3, r1, r0, r2)
|
|
goto L0
|
|
L50:
|
|
monitor-exit(r4) // Catch: java.lang.Throwable -> L71
|
|
return
|
|
L52:
|
|
java.lang.IllegalStateException r5 = new java.lang.IllegalStateException // Catch: java.lang.Throwable -> L71
|
|
java.lang.StringBuilder r0 = new java.lang.StringBuilder // Catch: java.lang.Throwable -> L71
|
|
r0.<init>() // Catch: java.lang.Throwable -> L71
|
|
java.lang.Class r1 = r4.getClass() // Catch: java.lang.Throwable -> L71
|
|
java.lang.String r1 = r1.getName() // Catch: java.lang.Throwable -> L71
|
|
r0.append(r1) // Catch: java.lang.Throwable -> L71
|
|
java.lang.String r1 = ".sizeOf() is reporting inconsistent results!"
|
|
r0.append(r1) // Catch: java.lang.Throwable -> L71
|
|
java.lang.String r0 = r0.toString() // Catch: java.lang.Throwable -> L71
|
|
r5.<init>(r0) // Catch: java.lang.Throwable -> L71
|
|
throw r5 // Catch: java.lang.Throwable -> L71
|
|
L71:
|
|
r5 = move-exception
|
|
monitor-exit(r4) // Catch: java.lang.Throwable -> L71
|
|
throw r5
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.collection.LruCache.a(int):void");
|
|
}
|
|
|
|
public final void a() {
|
|
a(-1);
|
|
}
|
|
}
|