<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package android.support.v4.util;

import java.util.LinkedHashMap;
import java.util.Map;

public class LruCache&lt;K, V&gt; {
    private int createCount;
    private int evictionCount;
    private int hitCount;
    private final LinkedHashMap&lt;K, V&gt; map;
    private int maxSize;
    private int missCount;
    private int putCount;
    private int size;

    /* access modifiers changed from: protected */
    public V create(K k) {
        return null;
    }

    /* access modifiers changed from: protected */
    public void entryRemoved(boolean z, K k, V v, V v2) {
    }

    /* access modifiers changed from: protected */
    public int sizeOf(K k, V v) {
        return 1;
    }

    public LruCache(int i) {
        if (i &gt; 0) {
            this.maxSize = i;
            this.map = new LinkedHashMap&lt;&gt;(0, 0.75f, true);
            return;
        }
        throw new IllegalArgumentException("maxSize &lt;= 0");
    }

    public void resize(int i) {
        if (i &gt; 0) {
            synchronized (this) {
                this.maxSize = i;
            }
            trimToSize(i);
            return;
        }
        throw new IllegalArgumentException("maxSize &lt;= 0");
    }

    /* JADX WARNING: Code restructure failed: missing block: B:10:0x001a, code lost:
        r0 = create(r5);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:11:0x001e, code lost:
        if (r0 != null) goto L_0x0022;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:12:0x0020, code lost:
        return null;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:13:0x0022, code lost:
        monitor-enter(r4);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:15:?, code lost:
        r4.createCount++;
        r1 = r4.map.put(r5, r0);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:16:0x002f, code lost:
        if (r1 == null) goto L_0x0037;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:17:0x0031, code lost:
        r4.map.put(r5, r1);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:18:0x0037, code lost:
        r4.size += safeSizeOf(r5, r0);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:19:0x0040, code lost:
        monitor-exit(r4);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:20:0x0041, code lost:
        if (r1 == null) goto L_0x0048;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:21:0x0043, code lost:
        entryRemoved(false, r5, r0, r1);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:22:0x0047, code lost:
        return r1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:23:0x0048, code lost:
        trimToSize(r4.maxSize);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:24:0x004d, code lost:
        return r0;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final V get(K r5) {
        /*
            r4 = this;
            if (r5 == 0) goto L_0x0054
            monitor-enter(r4)
            java.util.LinkedHashMap&lt;K, V&gt; r0 = r4.map     // Catch:{ all -&gt; 0x0051 }
            java.lang.Object r0 = r0.get(r5)     // Catch:{ all -&gt; 0x0051 }
            if (r0 == 0) goto L_0x0013
            int r5 = r4.hitCount     // Catch:{ all -&gt; 0x0051 }
            int r5 = r5 + 1
            r4.hitCount = r5     // Catch:{ all -&gt; 0x0051 }
            monitor-exit(r4)     // Catch:{ all -&gt; 0x0051 }
            return r0
        L_0x0013:
            int r0 = r4.missCount     // Catch:{ all -&gt; 0x0051 }
            int r0 = r0 + 1
            r4.missCount = r0     // Catch:{ all -&gt; 0x0051 }
            monitor-exit(r4)     // Catch:{ all -&gt; 0x0051 }
            java.lang.Object r0 = r4.create(r5)
            if (r0 != 0) goto L_0x0022
            r5 = 0
            return r5
        L_0x0022:
            monitor-enter(r4)
            int r1 = r4.createCount     // Catch:{ all -&gt; 0x004e }
            int r1 = r1 + 1
            r4.createCount = r1     // Catch:{ all -&gt; 0x004e }
            java.util.LinkedHashMap&lt;K, V&gt; r1 = r4.map     // Catch:{ all -&gt; 0x004e }
            java.lang.Object r1 = r1.put(r5, r0)     // Catch:{ all -&gt; 0x004e }
            if (r1 == 0) goto L_0x0037
            java.util.LinkedHashMap&lt;K, V&gt; r2 = r4.map     // Catch:{ all -&gt; 0x004e }
            r2.put(r5, r1)     // Catch:{ all -&gt; 0x004e }
            goto L_0x0040
        L_0x0037:
            int r2 = r4.size     // Catch:{ all -&gt; 0x004e }
            int r3 = r4.safeSizeOf(r5, r0)     // Catch:{ all -&gt; 0x004e }
            int r2 = r2 + r3
            r4.size = r2     // Catch:{ all -&gt; 0x004e }
        L_0x0040:
            monitor-exit(r4)     // Catch:{ all -&gt; 0x004e }
            if (r1 == 0) goto L_0x0048
            r2 = 0
            r4.entryRemoved(r2, r5, r0, r1)
            return r1
        L_0x0048:
            int r5 = r4.maxSize
            r4.trimToSize(r5)
            return r0
        L_0x004e:
            r5 = move-exception
            monitor-exit(r4)     // Catch:{ all -&gt; 0x004e }
            throw r5
        L_0x0051:
            r5 = move-exception
            monitor-exit(r4)     // Catch:{ all -&gt; 0x0051 }
            throw r5
        L_0x0054:
            java.lang.NullPointerException r5 = new java.lang.NullPointerException
            java.lang.String r0 = "key == null"
            r5.&lt;init&gt;(r0)
            throw r5
        */
        throw new UnsupportedOperationException("Method not decompiled: android.support.v4.util.LruCache.get(java.lang.Object):java.lang.Object");
    }

    public final V put(K k, V v) {
        V put;
        if (k == null || v == null) {
            throw new NullPointerException("key == null || value == null");
        }
        synchronized (this) {
            this.putCount++;
            this.size += safeSizeOf(k, v);
            put = this.map.put(k, v);
            if (put != null) {
                this.size -= safeSizeOf(k, put);
            }
        }
        if (put != null) {
            entryRemoved(false, k, put, v);
        }
        trimToSize(this.maxSize);
        return put;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:20:0x0070, code lost:
        throw new java.lang.IllegalStateException(getClass().getName() + ".sizeOf() is reporting inconsistent results!");
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public void trimToSize(int r5) {
        /*
            r4 = this;
        L_0x0000:
            monitor-enter(r4)
            int r0 = r4.size     // Catch:{ all -&gt; 0x0071 }
            if (r0 &lt; 0) goto L_0x0052
            java.util.LinkedHashMap&lt;K, V&gt; r0 = r4.map     // Catch:{ all -&gt; 0x0071 }
            boolean r0 = r0.isEmpty()     // Catch:{ all -&gt; 0x0071 }
            if (r0 == 0) goto L_0x0011
            int r0 = r4.size     // Catch:{ all -&gt; 0x0071 }
            if (r0 != 0) goto L_0x0052
        L_0x0011:
            int r0 = r4.size     // Catch:{ all -&gt; 0x0071 }
            if (r0 &lt;= r5) goto L_0x0050
            java.util.LinkedHashMap&lt;K, V&gt; r0 = r4.map     // Catch:{ all -&gt; 0x0071 }
            boolean r0 = r0.isEmpty()     // Catch:{ all -&gt; 0x0071 }
            if (r0 == 0) goto L_0x001e
            goto L_0x0050
        L_0x001e:
            java.util.LinkedHashMap&lt;K, V&gt; r0 = r4.map     // Catch:{ all -&gt; 0x0071 }
            java.util.Set r0 = r0.entrySet()     // Catch:{ all -&gt; 0x0071 }
            java.util.Iterator r0 = r0.iterator()     // Catch:{ all -&gt; 0x0071 }
            java.lang.Object r0 = r0.next()     // Catch:{ all -&gt; 0x0071 }
            java.util.Map$Entry r0 = (java.util.Map.Entry) r0     // Catch:{ all -&gt; 0x0071 }
            java.lang.Object r1 = r0.getKey()     // Catch:{ all -&gt; 0x0071 }
            java.lang.Object r0 = r0.getValue()     // Catch:{ all -&gt; 0x0071 }
            java.util.LinkedHashMap&lt;K, V&gt; r2 = r4.map     // Catch:{ all -&gt; 0x0071 }
            r2.remove(r1)     // Catch:{ all -&gt; 0x0071 }
            int r2 = r4.size     // Catch:{ all -&gt; 0x0071 }
            int r3 = r4.safeSizeOf(r1, r0)     // Catch:{ all -&gt; 0x0071 }
            int r2 = r2 - r3
            r4.size = r2     // Catch:{ all -&gt; 0x0071 }
            int r2 = r4.evictionCount     // Catch:{ all -&gt; 0x0071 }
            r3 = 1
            int r2 = r2 + r3
            r4.evictionCount = r2     // Catch:{ all -&gt; 0x0071 }
            monitor-exit(r4)     // Catch:{ all -&gt; 0x0071 }
            r2 = 0
            r4.entryRemoved(r3, r1, r0, r2)
            goto L_0x0000
        L_0x0050:
            monitor-exit(r4)     // Catch:{ all -&gt; 0x0071 }
            return
        L_0x0052:
            java.lang.IllegalStateException r5 = new java.lang.IllegalStateException     // Catch:{ all -&gt; 0x0071 }
            java.lang.StringBuilder r0 = new java.lang.StringBuilder     // Catch:{ all -&gt; 0x0071 }
            r0.&lt;init&gt;()     // Catch:{ all -&gt; 0x0071 }
            java.lang.Class r1 = r4.getClass()     // Catch:{ all -&gt; 0x0071 }
            java.lang.String r1 = r1.getName()     // Catch:{ all -&gt; 0x0071 }
            r0.append(r1)     // Catch:{ all -&gt; 0x0071 }
            java.lang.String r1 = ".sizeOf() is reporting inconsistent results!"
            r0.append(r1)     // Catch:{ all -&gt; 0x0071 }
            java.lang.String r0 = r0.toString()     // Catch:{ all -&gt; 0x0071 }
            r5.&lt;init&gt;(r0)     // Catch:{ all -&gt; 0x0071 }
            throw r5     // Catch:{ all -&gt; 0x0071 }
        L_0x0071:
            r5 = move-exception
            monitor-exit(r4)     // Catch:{ all -&gt; 0x0071 }
            throw r5
        */
        throw new UnsupportedOperationException("Method not decompiled: android.support.v4.util.LruCache.trimToSize(int):void");
    }

    public final V remove(K k) {
        V remove;
        if (k != null) {
            synchronized (this) {
                remove = this.map.remove(k);
                if (remove != null) {
                    this.size -= safeSizeOf(k, remove);
                }
            }
            if (remove != null) {
                entryRemoved(false, k, remove, (V) null);
            }
            return remove;
        }
        throw new NullPointerException("key == null");
    }

    private int safeSizeOf(K k, V v) {
        int sizeOf = sizeOf(k, v);
        if (sizeOf &gt;= 0) {
            return sizeOf;
        }
        throw new IllegalStateException("Negative size: " + k + "=" + v);
    }

    public final void evictAll() {
        trimToSize(-1);
    }

    public final synchronized int size() {
        return this.size;
    }

    public final synchronized int maxSize() {
        return this.maxSize;
    }

    public final synchronized int hitCount() {
        return this.hitCount;
    }

    public final synchronized int missCount() {
        return this.missCount;
    }

    public final synchronized int createCount() {
        return this.createCount;
    }

    public final synchronized int putCount() {
        return this.putCount;
    }

    public final synchronized int evictionCount() {
        return this.evictionCount;
    }

    public final synchronized Map&lt;K, V&gt; snapshot() {
        return new LinkedHashMap(this.map);
    }

    public final synchronized String toString() {
        int i;
        i = this.hitCount + this.missCount;
        return String.format("LruCache[maxSize=%d,hits=%d,misses=%d,hitRate=%d%%]", new Object[]{Integer.valueOf(this.maxSize), Integer.valueOf(this.hitCount), Integer.valueOf(this.missCount), Integer.valueOf(i != 0 ? (this.hitCount * 100) / i : 0)});
    }
}
</pre></body></html>