alexandroid/decompiled/jadx/sources/com/google/common/graph/MapRetrievalCache.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

75 lines
2.2 KiB
Java

package com.google.common.graph;
import com.google.common.base.Preconditions;
import java.util.Map;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* loaded from: classes8.dex */
final class MapRetrievalCache<K, V> extends MapIteratorCache<K, V> {
private volatile transient CacheEntry<K, V> cacheEntry1;
private volatile transient CacheEntry<K, V> cacheEntry2;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
public static final class CacheEntry<K, V> {
final K key;
final V value;
public CacheEntry(K k, V v) {
this.key = k;
this.value = v;
}
}
public MapRetrievalCache(Map<K, V> map) {
super(map);
}
private void addToCache(K k, V v) {
addToCache(new CacheEntry<>(k, v));
}
@Override // com.google.common.graph.MapIteratorCache
public void clearCache() {
super.clearCache();
this.cacheEntry1 = null;
this.cacheEntry2 = null;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.graph.MapIteratorCache
public V get(Object obj) {
Preconditions.checkNotNull(obj);
V ifCached = getIfCached(obj);
if (ifCached != null) {
return ifCached;
}
V withoutCaching = getWithoutCaching(obj);
if (withoutCaching != null) {
addToCache(obj, withoutCaching);
}
return withoutCaching;
}
@Override // com.google.common.graph.MapIteratorCache
public V getIfCached(Object obj) {
V v = (V) super.getIfCached(obj);
if (v != null) {
return v;
}
CacheEntry<K, V> cacheEntry = this.cacheEntry1;
if (cacheEntry != null && cacheEntry.key == obj) {
return cacheEntry.value;
}
CacheEntry<K, V> cacheEntry2 = this.cacheEntry2;
if (cacheEntry2 == null || cacheEntry2.key != obj) {
return null;
}
addToCache(cacheEntry2);
return cacheEntry2.value;
}
private void addToCache(CacheEntry<K, V> cacheEntry) {
this.cacheEntry2 = this.cacheEntry1;
this.cacheEntry1 = cacheEntry;
}
}