alexandroid/decompiled/jadx/sources/androidx/collection/LruCache.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

339 lines
16 KiB
Java

package androidx.collection;
import androidx.annotation.IntRange;
import androidx.collection.internal.Lock;
import androidx.collection.internal.LruHashMap;
import androidx.collection.internal.RuntimeHelpersKt;
import androidx.exifinterface.media.ExifInterface;
import com.amazon.alexa.auth.BuildConfig;
import com.amazon.clouddrive.extended.model.BulkOperationType;
import com.dee.app.metrics.MetricsConstants;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.internal.SourceDebugExtension;
import org.aspectj.lang.JoinPoint;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@Metadata(d1 = {"\u0000@\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u000e\n\u0002\u0010%\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\b\u0016\u0018\u0000*\b\b\u0000\u0010\u0001*\u00020\u0002*\b\b\u0001\u0010\u0003*\u00020\u00022\u00020\u0002B\u000f\u0012\b\b\u0001\u0010\u0004\u001a\u00020\u0005¢\u0006\u0002\u0010\u0006J\u0017\u0010\u0011\u001a\u0004\u0018\u00018\u00012\u0006\u0010\u0012\u001a\u00028\u0000H\u0014¢\u0006\u0002\u0010\u0013J\u0006\u0010\u0007\u001a\u00020\u0005J/\u0010\u0014\u001a\u00020\u00152\u0006\u0010\u0016\u001a\u00020\u00172\u0006\u0010\u0012\u001a\u00028\u00002\u0006\u0010\u0018\u001a\u00028\u00012\b\u0010\u0019\u001a\u0004\u0018\u00018\u0001H\u0014¢\u0006\u0002\u0010\u001aJ\u0006\u0010\u001b\u001a\u00020\u0015J\u0006\u0010\b\u001a\u00020\u0005J\u0018\u0010\u001c\u001a\u0004\u0018\u00018\u00012\u0006\u0010\u0012\u001a\u00028\u0000H\u0086\u0002¢\u0006\u0002\u0010\u0013J\u0006\u0010\t\u001a\u00020\u0005J\u0006\u0010\u0004\u001a\u00020\u0005J\u0006\u0010\u000e\u001a\u00020\u0005J\u001d\u0010\u001d\u001a\u0004\u0018\u00018\u00012\u0006\u0010\u0012\u001a\u00028\u00002\u0006\u0010\u001e\u001a\u00028\u0001¢\u0006\u0002\u0010\u001fJ\u0006\u0010\u000f\u001a\u00020\u0005J\u0015\u0010 \u001a\u0004\u0018\u00018\u00012\u0006\u0010\u0012\u001a\u00028\u0000¢\u0006\u0002\u0010\u0013J\u0012\u0010!\u001a\u00020\u00152\b\b\u0001\u0010\u0004\u001a\u00020\u0005H\u0016J\u001d\u0010\"\u001a\u00020\u00052\u0006\u0010\u0012\u001a\u00028\u00002\u0006\u0010\u001e\u001a\u00028\u0001H\u0002¢\u0006\u0002\u0010#J\u0006\u0010\u0010\u001a\u00020\u0005J\u001d\u0010$\u001a\u00020\u00052\u0006\u0010\u0012\u001a\u00028\u00002\u0006\u0010\u001e\u001a\u00028\u0001H\u0014¢\u0006\u0002\u0010#J\u0012\u0010%\u001a\u000e\u0012\u0004\u0012\u00028\u0000\u0012\u0004\u0012\u00028\u00010&J\b\u0010'\u001a\u00020(H\u0016J\u0010\u0010)\u001a\u00020\u00152\u0006\u0010\u0004\u001a\u00020\u0005H\u0016R\u000e\u0010\u0007\u001a\u00020\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u000bX\u0082\u0004¢\u0006\u0002\n\u0000R\u001a\u0010\f\u001a\u000e\u0012\u0004\u0012\u00028\u0000\u0012\u0004\u0012\u00028\u00010\rX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u000e\u001a\u00020\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u000f\u001a\u00020\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0010\u001a\u00020\u0005X\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006*"}, d2 = {"Landroidx/collection/LruCache;", "K", "", ExifInterface.GPS_MEASUREMENT_INTERRUPTED, "maxSize", "", "(I)V", "createCount", "evictionCount", "hitCount", JoinPoint.SYNCHRONIZATION_LOCK, "Landroidx/collection/internal/Lock;", BuildConfig.FLAVOR_authType, "Landroidx/collection/internal/LruHashMap;", "missCount", "putCount", "size", "create", "key", "(Ljava/lang/Object;)Ljava/lang/Object;", "entryRemoved", "", "evicted", "", "oldValue", "newValue", "(ZLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V", "evictAll", MetricsConstants.Method.CACHE_GET, MetricsConstants.Method.CACHE_PUT, "value", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", BulkOperationType.remove, "resize", "safeSizeOf", "(Ljava/lang/Object;Ljava/lang/Object;)I", "sizeOf", "snapshot", "", "toString", "", "trimToSize", "collection"}, k = 1, mv = {1, 9, 0}, xi = 48)
@SourceDebugExtension({"SMAP\nLruCache.kt\nKotlin\n*S Kotlin\n*F\n+ 1 LruCache.kt\nandroidx/collection/LruCache\n+ 2 RuntimeHelpers.kt\nandroidx/collection/internal/RuntimeHelpersKt\n+ 3 LockExt.kt\nandroidx/collection/internal/LockExtKt\n+ 4 Lock.jvm.kt\nandroidx/collection/internal/Lock\n+ 5 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n*L\n1#1,356:1\n59#2,5:357\n59#2,5:362\n45#2,5:382\n45#2,5:390\n26#3,2:367\n26#3,2:370\n26#3,2:373\n26#3,2:376\n26#3,2:379\n26#3,2:387\n26#3,2:395\n26#3,2:398\n26#3,2:401\n26#3,2:404\n26#3,2:407\n26#3,2:410\n26#3,2:413\n26#3,2:416\n26#3,2:421\n26#4:369\n26#4:372\n26#4:375\n26#4:378\n26#4:381\n26#4:389\n26#4:397\n26#4:400\n26#4:403\n26#4:406\n26#4:409\n26#4:412\n26#4:415\n26#4:418\n26#4:423\n1855#5,2:419\n*S KotlinDebug\n*F\n+ 1 LruCache.kt\nandroidx/collection/LruCache\n*L\n62#1:357,5\n83#1:362,5\n170#1:382,5\n245#1:390,5\n85#1:367,2\n96#1:370,2\n113#1:373,2\n140#1:376,2\n169#1:379,2\n198#1:387,2\n267#1:395,2\n274#1:398,2\n277#1:401,2\n280#1:404,2\n283#1:407,2\n286#1:410,2\n289#1:413,2\n298#1:416,2\n306#1:421,2\n85#1:369\n96#1:372\n113#1:375\n140#1:378\n169#1:381\n198#1:389\n267#1:397\n274#1:400\n277#1:403\n280#1:406\n283#1:409\n286#1:412\n289#1:415\n298#1:418\n306#1:423\n300#1:419,2\n*E\n"})
/* loaded from: classes.dex */
public class LruCache<K, V> {
private int createCount;
private int evictionCount;
private int hitCount;
@NotNull
private final Lock lock;
@NotNull
private final LruHashMap<K, V> map;
private int maxSize;
private int missCount;
private int putCount;
private int size;
public LruCache(@IntRange(from = 1, to = 2147483647L) int i) {
this.maxSize = i;
if (!(i > 0)) {
RuntimeHelpersKt.throwIllegalArgumentException("maxSize <= 0");
}
this.map = new LruHashMap<>(0, 0.75f);
this.lock = new Lock();
}
private final int safeSizeOf(K key, V value) {
int sizeOf = sizeOf(key, value);
if (!(sizeOf >= 0)) {
RuntimeHelpersKt.throwIllegalStateException("Negative size: " + key + '=' + value);
}
return sizeOf;
}
@Nullable
public V create(@NotNull K key) {
key.getClass();
return null;
}
public final int createCount() {
int i;
synchronized (this.lock) {
i = this.createCount;
}
return i;
}
public void entryRemoved(boolean evicted, @NotNull K key, @NotNull V oldValue, @Nullable V newValue) {
key.getClass();
oldValue.getClass();
}
public final void evictAll() {
trimToSize(-1);
}
public final int evictionCount() {
int i;
synchronized (this.lock) {
i = this.evictionCount;
}
return i;
}
@Nullable
public final V get(@NotNull K key) {
V v;
key.getClass();
synchronized (this.lock) {
V v2 = this.map.get(key);
if (v2 != null) {
this.hitCount++;
return v2;
}
this.missCount++;
V create = create(key);
if (create == null) {
return null;
}
synchronized (this.lock) {
try {
this.createCount++;
v = (V) this.map.put(key, create);
if (v != null) {
this.map.put(key, v);
} else {
this.size += safeSizeOf(key, create);
Unit unit = Unit.INSTANCE;
}
} catch (Throwable th) {
throw th;
}
}
if (v != null) {
entryRemoved(false, key, create, v);
return v;
}
trimToSize(this.maxSize);
return create;
}
}
public final int hitCount() {
int i;
synchronized (this.lock) {
i = this.hitCount;
}
return i;
}
public final int maxSize() {
int i;
synchronized (this.lock) {
i = this.maxSize;
}
return i;
}
public final int missCount() {
int i;
synchronized (this.lock) {
i = this.missCount;
}
return i;
}
@Nullable
public final V put(@NotNull K key, @NotNull V value) {
V put;
key.getClass();
value.getClass();
synchronized (this.lock) {
try {
this.putCount++;
this.size += safeSizeOf(key, value);
put = this.map.put(key, value);
if (put != null) {
this.size -= safeSizeOf(key, put);
}
Unit unit = Unit.INSTANCE;
} catch (Throwable th) {
throw th;
}
}
if (put != null) {
entryRemoved(false, key, put, value);
}
trimToSize(this.maxSize);
return put;
}
public final int putCount() {
int i;
synchronized (this.lock) {
i = this.putCount;
}
return i;
}
@Nullable
public final V remove(@NotNull K key) {
V remove;
key.getClass();
synchronized (this.lock) {
try {
remove = this.map.remove(key);
if (remove != null) {
this.size -= safeSizeOf(key, remove);
}
Unit unit = Unit.INSTANCE;
} catch (Throwable th) {
throw th;
}
}
if (remove != null) {
entryRemoved(false, key, remove, null);
}
return remove;
}
public void resize(@IntRange(from = 1, to = 2147483647L) int maxSize) {
if (!(maxSize > 0)) {
RuntimeHelpersKt.throwIllegalArgumentException("maxSize <= 0");
}
synchronized (this.lock) {
this.maxSize = maxSize;
Unit unit = Unit.INSTANCE;
}
trimToSize(maxSize);
}
public final int size() {
int i;
synchronized (this.lock) {
i = this.size;
}
return i;
}
public int sizeOf(@NotNull K key, @NotNull V value) {
key.getClass();
value.getClass();
return 1;
}
/* JADX WARN: Multi-variable type inference failed */
@NotNull
public final Map<K, V> snapshot() {
LinkedHashMap linkedHashMap;
synchronized (this.lock) {
linkedHashMap = new LinkedHashMap(this.map.getEntries().size());
Iterator<T> it2 = this.map.getEntries().iterator();
while (it2.hasNext()) {
Map.Entry entry = (Map.Entry) it2.next();
linkedHashMap.put(entry.getKey(), entry.getValue());
}
}
return linkedHashMap;
}
@NotNull
public String toString() {
String str;
synchronized (this.lock) {
try {
int i = this.hitCount;
int i2 = this.missCount + i;
str = "LruCache[maxSize=" + this.maxSize + ",hits=" + this.hitCount + ",misses=" + this.missCount + ",hitRate=" + (i2 != 0 ? (i * 100) / i2 : 0) + "%]";
} catch (Throwable th) {
throw th;
}
}
return str;
}
/* JADX WARN: Code restructure failed: missing block: B:30:0x0062, code lost:
return;
*/
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Removed duplicated region for block: B:13:0x001c A[Catch: all -> 0x0015, TryCatch #0 {all -> 0x0015, blocks: (B:4:0x0003, B:6:0x0008, B:8:0x0010, B:13:0x001c, B:14:0x0021, B:16:0x0025, B:18:0x002e, B:20:0x0040), top: B:3:0x0003 }] */
/* JADX WARN: Removed duplicated region for block: B:20:0x0040 A[Catch: all -> 0x0015, TRY_ENTER, TRY_LEAVE, TryCatch #0 {all -> 0x0015, blocks: (B:4:0x0003, B:6:0x0008, B:8:0x0010, B:13:0x001c, B:14:0x0021, B:16:0x0025, B:18:0x002e, B:20:0x0040), top: B:3:0x0003 }] */
/* JADX WARN: Removed duplicated region for block: B:23:0x003e A[SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public void trimToSize(int r7) {
/*
r6 = this;
L0:
androidx.collection.internal.Lock r0 = r6.lock
monitor-enter(r0)
int r1 = r6.size // Catch: java.lang.Throwable -> L15
r2 = 1
if (r1 < 0) goto L19
androidx.collection.internal.LruHashMap<K, V> r1 = r6.map // Catch: java.lang.Throwable -> L15
boolean r1 = r1.isEmpty() // Catch: java.lang.Throwable -> L15
if (r1 == 0) goto L17
int r1 = r6.size // Catch: java.lang.Throwable -> L15
if (r1 != 0) goto L19
goto L17
L15:
r6 = move-exception
goto L63
L17:
r1 = r2
goto L1a
L19:
r1 = 0
L1a:
if (r1 != 0) goto L21
java.lang.String r1 = "LruCache.sizeOf() is reporting inconsistent results!"
androidx.collection.internal.RuntimeHelpersKt.throwIllegalStateException(r1) // Catch: java.lang.Throwable -> L15
L21:
int r1 = r6.size // Catch: java.lang.Throwable -> L15
if (r1 <= r7) goto L61
androidx.collection.internal.LruHashMap<K, V> r1 = r6.map // Catch: java.lang.Throwable -> L15
boolean r1 = r1.isEmpty() // Catch: java.lang.Throwable -> L15
if (r1 == 0) goto L2e
goto L61
L2e:
androidx.collection.internal.LruHashMap<K, V> r1 = r6.map // Catch: java.lang.Throwable -> L15
java.util.Set r1 = r1.getEntries() // Catch: java.lang.Throwable -> L15
java.lang.Iterable r1 = (java.lang.Iterable) r1 // Catch: java.lang.Throwable -> L15
java.lang.Object r1 = kotlin.collections.CollectionsKt.firstOrNull(r1) // Catch: java.lang.Throwable -> L15
java.util.Map$Entry r1 = (java.util.Map.Entry) r1 // Catch: java.lang.Throwable -> L15
if (r1 != 0) goto L40
monitor-exit(r0)
return
L40:
java.lang.Object r3 = r1.getKey() // Catch: java.lang.Throwable -> L15
java.lang.Object r1 = r1.getValue() // Catch: java.lang.Throwable -> L15
androidx.collection.internal.LruHashMap<K, V> r4 = r6.map // Catch: java.lang.Throwable -> L15
r4.remove(r3) // Catch: java.lang.Throwable -> L15
int r4 = r6.size // Catch: java.lang.Throwable -> L15
int r5 = r6.safeSizeOf(r3, r1) // Catch: java.lang.Throwable -> L15
int r4 = r4 - r5
r6.size = r4 // Catch: java.lang.Throwable -> L15
int r4 = r6.evictionCount // Catch: java.lang.Throwable -> L15
int r4 = r4 + r2
r6.evictionCount = r4 // Catch: java.lang.Throwable -> L15
monitor-exit(r0)
r0 = 0
r6.entryRemoved(r2, r3, r1, r0)
goto L0
L61:
monitor-exit(r0)
return
L63:
monitor-exit(r0)
throw r6
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.collection.LruCache.trimToSize(int):void");
}
}