diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/BigInt.scala | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/library/scala/BigInt.scala b/src/library/scala/BigInt.scala index 09f5fa08f2..0878d0d7aa 100644 --- a/src/library/scala/BigInt.scala +++ b/src/library/scala/BigInt.scala @@ -31,8 +31,9 @@ object BigInt { */ def apply(i: Int): BigInt = if (minCached <= i && i <= maxCached) { - var n = cache(i) - if (n eq null) { n = new BigInt(BigInteger.valueOf(i)); cache(i) = n } + val offset = i - minCached + var n = cache(offset) + if (n eq null) { n = new BigInt(BigInteger.valueOf(i)); cache(offset) = n } n } else new BigInt(BigInteger.valueOf(i)) |