Put constants in decimal cache
This commit is contained in:
parent
20bbaec62a
commit
8c32a2cd7a
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user