package k.a.q.y;

import j.q;

/* JADX INFO: compiled from: CharArrayPool.kt */
/* JADX INFO: loaded from: classes.dex */
public final class d {
    public static final d a = new d();
    private static final j.k0.e<char[]> b = new j.k0.e<>();
    private static int c;
    private static final int d;

    static {
        Object objA;
        try {
            q.a aVar = j.q.b;
            String property = System.getProperty("kotlinx.serialization.json.pool.size");
            j.p0.d.r.e(property, "getProperty(\"kotlinx.ser…lization.json.pool.size\")");
            objA = j.u0.p.k(property);
            j.q.a(objA);
        } catch (Throwable th) {
            q.a aVar2 = j.q.b;
            objA = j.r.a(th);
            j.q.a(objA);
        }
        if (j.q.d(objA)) {
            objA = null;
        }
        Integer num = (Integer) objA;
        d = num != null ? num.intValue() : 1048576;
    }

    private d() {
    }

    public final void a(char[] cArr) {
        j.p0.d.r.f(cArr, "array");
        synchronized (this) {
            if (c + cArr.length < d) {
                c += cArr.length;
                b.e(cArr);
            }
            j.h0 h0Var = j.h0.a;
        }
    }

    public final char[] b() {
        char[] cArrO;
        synchronized (this) {
            cArrO = b.o();
            if (cArrO != null) {
                c -= cArrO.length;
            } else {
                cArrO = null;
            }
        }
        return cArrO == null ? new char[128] : cArrO;
    }
}
