package androidx.collection; import java.util.LinkedHashMap; import java.util.Locale; import java.util.Map; /* loaded from: classes.dex */ public class e { private int createCount; private int evictionCount; private int hitCount; private final LinkedHashMap map; private int maxSize; private int missCount; private int putCount; private int size; public e(int i10) { if (i10 <= 0) { throw new IllegalArgumentException("maxSize <= 0"); } this.maxSize = i10; this.map = new LinkedHashMap<>(0, 0.75f, true); } private int a(Object obj, Object obj2) { int sizeOf = sizeOf(obj, obj2); if (sizeOf >= 0) { return sizeOf; } throw new IllegalStateException("Negative size: " + obj + "=" + obj2); } protected Object create(Object obj) { return null; } public final synchronized int createCount() { return this.createCount; } protected void entryRemoved(boolean z10, Object obj, Object obj2, Object obj3) { } public final void evictAll() { trimToSize(-1); } public final synchronized int evictionCount() { return this.evictionCount; } public final Object get(Object obj) { Object put; if (obj == null) { throw new NullPointerException("key == null"); } synchronized (this) { Object obj2 = this.map.get(obj); if (obj2 != null) { this.hitCount++; return obj2; } this.missCount++; Object create = create(obj); if (create == null) { return null; } synchronized (this) { this.createCount++; put = this.map.put(obj, create); if (put != null) { this.map.put(obj, put); } else { this.size += a(obj, create); } } if (put != null) { entryRemoved(false, obj, create, put); return put; } trimToSize(this.maxSize); return create; } } public final synchronized int hitCount() { return this.hitCount; } public final synchronized int maxSize() { return this.maxSize; } public final synchronized int missCount() { return this.missCount; } public final Object put(Object obj, Object obj2) { Object put; if (obj == null || obj2 == null) { throw new NullPointerException("key == null || value == null"); } synchronized (this) { this.putCount++; this.size += a(obj, obj2); put = this.map.put(obj, obj2); if (put != null) { this.size -= a(obj, put); } } if (put != null) { entryRemoved(false, obj, put, obj2); } trimToSize(this.maxSize); return put; } public final synchronized int putCount() { return this.putCount; } public final Object remove(Object obj) { Object remove; if (obj == null) { throw new NullPointerException("key == null"); } synchronized (this) { remove = this.map.remove(obj); if (remove != null) { this.size -= a(obj, remove); } } if (remove != null) { entryRemoved(false, obj, remove, null); } return remove; } public void resize(int i10) { if (i10 <= 0) { throw new IllegalArgumentException("maxSize <= 0"); } synchronized (this) { this.maxSize = i10; } trimToSize(i10); } public final synchronized int size() { return this.size; } protected int sizeOf(Object obj, Object obj2) { return 1; } public final synchronized Map snapshot() { return new LinkedHashMap(this.map); } public final synchronized String toString() { int i10; int i11; i10 = this.hitCount; i11 = this.missCount + i10; return String.format(Locale.US, "LruCache[maxSize=%d,hits=%d,misses=%d,hitRate=%d%%]", Integer.valueOf(this.maxSize), Integer.valueOf(this.hitCount), Integer.valueOf(this.missCount), Integer.valueOf(i11 != 0 ? (i10 * 100) / i11 : 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 trimToSize(int r5) { /* r4 = this; L0: monitor-enter(r4) int r0 = r4.size // Catch: java.lang.Throwable -> L71 if (r0 < 0) goto L52 java.util.LinkedHashMap r0 = r4.map // Catch: java.lang.Throwable -> L71 boolean r0 = r0.isEmpty() // Catch: java.lang.Throwable -> L71 if (r0 == 0) goto L11 int r0 = r4.size // Catch: java.lang.Throwable -> L71 if (r0 != 0) goto L52 L11: int r0 = r4.size // Catch: java.lang.Throwable -> L71 if (r0 <= r5) goto L50 java.util.LinkedHashMap r0 = r4.map // 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 r0 = r4.map // 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 r2 = r4.map // Catch: java.lang.Throwable -> L71 r2.remove(r1) // Catch: java.lang.Throwable -> L71 int r2 = r4.size // Catch: java.lang.Throwable -> L71 int r3 = r4.a(r1, r0) // Catch: java.lang.Throwable -> L71 int r2 = r2 - r3 r4.size = r2 // Catch: java.lang.Throwable -> L71 int r2 = r4.evictionCount // Catch: java.lang.Throwable -> L71 r3 = 1 int r2 = r2 + r3 r4.evictionCount = r2 // Catch: java.lang.Throwable -> L71 monitor-exit(r4) // Catch: java.lang.Throwable -> L71 r2 = 0 r4.entryRemoved(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.() // 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.(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.e.trimToSize(int):void"); } }