Put constants in decimal cache

This commit is contained in:
DBotThePony 2023-04-14 23:58:17 +07:00
parent 20bbaec62a
commit 8c32a2cd7a
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -746,6 +746,14 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0
private val cache = Array(2048) { Decimal(it - 1024, 0.0) }
init {
cache[1024] = ZERO
cache[1025] = ONE
cache[1023] = MINUS_ONE
cache[1026] = TWO
cache[1034] = TEN
}
/**
* Returns pooled value if present, otherwise constructs new object
*/