From b4c07d331dd467eb2346ae6a4751650d5c737bba Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 3 Sep 2022 16:20:13 +0700 Subject: [PATCH] widen imprecise fraction cache --- .../kotlin/ru/dbotthepony/mc/otm/core/ImpreciseFraction.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ImpreciseFraction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/ImpreciseFraction.kt index e84b3e9de..43b444c56 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/ImpreciseFraction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/ImpreciseFraction.kt @@ -580,13 +580,13 @@ class ImpreciseFraction @JvmOverloads constructor(whole: BigInteger, decimal: Do @JvmField val DOUBLE_MAX_VALUE = ImpreciseFraction(BI_DOUBLE_MAX) @JvmField val DOUBLE_MIN_VALUE = ImpreciseFraction(BI_DOUBLE_MIN) - private val cache = Array(256) { ImpreciseFraction(it - 128) } + private val cache = Array(2048) { ImpreciseFraction(it - 1024) } /** * Returns pooled value if present, otherwise constructs new object */ fun valueOf(value: Int): ImpreciseFraction { - if (value in -128 .. 127) { + if (value in -1024 .. 1024) { return cache[value + 128] } @@ -597,7 +597,7 @@ class ImpreciseFraction @JvmOverloads constructor(whole: BigInteger, decimal: Do * Returns pooled value if present, otherwise constructs new object */ fun valueOf(value: Long): ImpreciseFraction { - if (value in -128 .. 127) { + if (value in -1024L .. 1024L) { return cache[value.toInt()] }