ThreadLocalCache.smali

.class public Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;
.super Ljava/lang/Object;


# static fields
.field public static final BYTES_CACH_INIT_SIZE:I = 0x400

.field public static final BYTES_CACH_INIT_SIZE_EXP:I = 0xa

.field public static final BYTES_CACH_MAX_SIZE:I = 0x20000

.field public static final BYTES_CACH_MAX_SIZE_EXP:I = 0x11

.field public static final CHARS_CACH_INIT_SIZE:I = 0x400

.field public static final CHARS_CACH_INIT_SIZE_EXP:I = 0xa

.field public static final CHARS_CACH_MAX_SIZE:I = 0x20000

.field public static final CHARS_CACH_MAX_SIZE_EXP:I = 0x11

.field static final synthetic a:Z

.field private static final b:Ljava/lang/ThreadLocal;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/lang/ThreadLocal<",
            "Ljava/lang/ref/SoftReference<",
            "[C>;>;"
        }
    .end annotation
.end field

.field private static final c:Ljava/lang/ThreadLocal;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/lang/ThreadLocal<",
            "Ljava/nio/charset/CharsetDecoder;",
            ">;"
        }
    .end annotation
.end field

.field private static final d:Ljava/lang/ThreadLocal;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/lang/ThreadLocal<",
            "Ljava/lang/ref/SoftReference<",
            "[B>;>;"
        }
    .end annotation
.end field


# direct methods
.method static constructor <clinit>()V
    .registers 1

    const-class v0, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;

    invoke-virtual {v0}, Ljava/lang/Class;->desiredAssertionStatus()Z

    move-result v0

    xor-int/lit8 v0, v0, 0x1

    sput-boolean v0, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->a:Z

    new-instance v0, Ljava/lang/ThreadLocal;

    invoke-direct {v0}, Ljava/lang/ThreadLocal;-><init>()V

    sput-object v0, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->b:Ljava/lang/ThreadLocal;

    new-instance v0, Ljava/lang/ThreadLocal;

    invoke-direct {v0}, Ljava/lang/ThreadLocal;-><init>()V

    sput-object v0, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->c:Ljava/lang/ThreadLocal;

    new-instance v0, Ljava/lang/ThreadLocal;

    invoke-direct {v0}, Ljava/lang/ThreadLocal;-><init>()V

    sput-object v0, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->d:Ljava/lang/ThreadLocal;

    return-void
.end method

.method public constructor <init>()V
    .registers 1

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method private static a(III)I
    .registers 5

    sget-boolean v0, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->a:Z

    const/4 v1, 0x1

    if-nez v0, :cond_10

    shl-int p1, v1, p1

    if-lt p1, p2, :cond_a

    goto :goto_10

    :cond_a
    new-instance p0, Ljava/lang/AssertionError;

    invoke-direct {p0}, Ljava/lang/AssertionError;-><init>()V

    throw p0

    :cond_10
    :goto_10
    ushr-int p1, p2, p0

    if-gtz p1, :cond_17

    shl-int p0, v1, p0

    return p0

    :cond_17
    sub-int/2addr p2, v1

    invoke-static {p2}, Ljava/lang/Integer;->numberOfLeadingZeros(I)I

    move-result p0

    rsub-int/lit8 p0, p0, 0x20

    shl-int p0, v1, p0

    return p0
.end method

.method private static a(I)[C
    .registers 3

    const/high16 v0, 0x20000

    if-le p0, v0, :cond_7

    new-array p0, p0, [C

    return-object p0

    :cond_7
    const/16 v0, 0xa

    const/16 v1, 0x11

    invoke-static {v0, v1, p0}, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->a(III)I

    move-result p0

    new-array p0, p0, [C

    sget-object v0, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->b:Ljava/lang/ThreadLocal;

    new-instance v1, Ljava/lang/ref/SoftReference;

    invoke-direct {v1, p0}, Ljava/lang/ref/SoftReference;-><init>(Ljava/lang/Object;)V

    invoke-virtual {v0, v1}, Ljava/lang/ThreadLocal;->set(Ljava/lang/Object;)V

    return-object p0
.end method

.method private static b(I)[B
    .registers 3

    const/high16 v0, 0x20000

    if-le p0, v0, :cond_7

    new-array p0, p0, [B

    return-object p0

    :cond_7
    const/16 v0, 0xa

    const/16 v1, 0x11

    invoke-static {v0, v1, p0}, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->a(III)I

    move-result p0

    new-array p0, p0, [B

    sget-object v0, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->d:Ljava/lang/ThreadLocal;

    new-instance v1, Ljava/lang/ref/SoftReference;

    invoke-direct {v1, p0}, Ljava/lang/ref/SoftReference;-><init>(Ljava/lang/Object;)V

    invoke-virtual {v0, v1}, Ljava/lang/ThreadLocal;->set(Ljava/lang/Object;)V

    return-object p0
.end method

.method public static clearBytes()V
    .registers 2

    sget-object v0, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->d:Ljava/lang/ThreadLocal;

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Ljava/lang/ThreadLocal;->set(Ljava/lang/Object;)V

    return-void
.end method

.method public static clearChars()V
    .registers 2

    sget-object v0, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->b:Ljava/lang/ThreadLocal;

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Ljava/lang/ThreadLocal;->set(Ljava/lang/Object;)V

    return-void
.end method

.method public static getBytes(I)[B
    .registers 3

    sget-object v0, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->d:Ljava/lang/ThreadLocal;

    invoke-virtual {v0}, Ljava/lang/ThreadLocal;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/ref/SoftReference;

    if-nez v0, :cond_f

    invoke-static {p0}, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->b(I)[B

    move-result-object p0

    return-object p0

    :cond_f
    invoke-virtual {v0}, Ljava/lang/ref/SoftReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, [B

    if-nez v0, :cond_1c

    invoke-static {p0}, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->b(I)[B

    move-result-object p0

    return-object p0

    :cond_1c
    array-length v1, v0

    if-ge v1, p0, :cond_23

    invoke-static {p0}, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->b(I)[B

    move-result-object v0

    :cond_23
    return-object v0
.end method

.method public static getChars(I)[C
    .registers 3

    sget-object v0, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->b:Ljava/lang/ThreadLocal;

    invoke-virtual {v0}, Ljava/lang/ThreadLocal;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/ref/SoftReference;

    if-nez v0, :cond_f

    invoke-static {p0}, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->a(I)[C

    move-result-object p0

    return-object p0

    :cond_f
    invoke-virtual {v0}, Ljava/lang/ref/SoftReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, [C

    if-nez v0, :cond_1c

    invoke-static {p0}, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->a(I)[C

    move-result-object p0

    return-object p0

    :cond_1c
    array-length v1, v0

    if-ge v1, p0, :cond_23

    invoke-static {p0}, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->a(I)[C

    move-result-object v0

    :cond_23
    return-object v0
.end method

.method public static getUTF8Decoder()Ljava/nio/charset/CharsetDecoder;
    .registers 2

    sget-object v0, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->c:Ljava/lang/ThreadLocal;

    invoke-virtual {v0}, Ljava/lang/ThreadLocal;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/nio/charset/CharsetDecoder;

    if-nez v0, :cond_14

    new-instance v0, Lcom/tradplus/ads/common/serialization/util/UTF8Decoder;

    invoke-direct {v0}, Lcom/tradplus/ads/common/serialization/util/UTF8Decoder;-><init>()V

    sget-object v1, Lcom/tradplus/ads/common/serialization/util/ThreadLocalCache;->c:Ljava/lang/ThreadLocal;

    invoke-virtual {v1, v0}, Ljava/lang/ThreadLocal;->set(Ljava/lang/Object;)V

    :cond_14
    return-object v0
.end method