package e.a.r.y;

import d.q;

/* JADX INFO: compiled from: CharArrayPool.kt */
/* JADX INFO: loaded from: classes.dex */
@d.n
public final class d {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final d f3004a = new d();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private static final d.j0.e<char[]> f3005b = new d.j0.e<>();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private static int f3006c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private static final int f3007d;

    static {
        Object objA;
        try {
            q.a aVar = d.q.f2687c;
            String property = System.getProperty("kotlinx.serialization.json.pool.size");
            d.n0.c.s.d(property, "getProperty(\"kotlinx.ser…lization.json.pool.size\")");
            objA = d.q.a(d.s0.p.h(property));
        } catch (Throwable th) {
            q.a aVar2 = d.q.f2687c;
            objA = d.q.a(d.r.a(th));
        }
        if (d.q.c(objA)) {
            objA = null;
        }
        Integer num = (Integer) objA;
        f3007d = num != null ? num.intValue() : 1048576;
    }

    private d() {
    }

    public final void a(char[] cArr) {
        d.n0.c.s.e(cArr, "array");
        synchronized (this) {
            int i = f3006c;
            if (cArr.length + i < f3007d) {
                f3006c = i + cArr.length;
                f3005b.addLast(cArr);
            }
            d.g0 g0Var = d.g0.f2578a;
        }
    }

    public final char[] b() {
        char[] cArrJ;
        synchronized (this) {
            cArrJ = f3005b.j();
            if (cArrJ != null) {
                f3006c -= cArrJ.length;
            } else {
                cArrJ = null;
            }
        }
        return cArrJ == null ? new char[128] : cArrJ;
    }
}
