widen imprecise fraction cache

This commit is contained in:
DBotThePony 2022-09-03 16:20:13 +07:00
parent 5a5288c0a2
commit b4c07d331d
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -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()]
}