So do we have consensus on this version? Thanks for the lively "conversation."
Brian On Jun 26, 2013, at 12:05 AM, Aleksey Shipilev wrote: > Yes, like that. > > -Aleksey > > On 26.06.2013, at 10:53, Dmitry Nadezhin <dmitry.nadez...@gmail.com> wrote: > >>> We could check for the existing cacheLine.length right before installing >> the new one >> >> Do you mean something like this ? >> >> BigInteger getRadixConversionCache(int radix, int exponent) { >> BigInteger[] cacheLine = powerCache[radix]; // volatile read >> if (exponent < cacheLine.length) >> return cacheLine[exponent]; >> >> int oldLength = cacheLine.length; >> cacheLine = Arrays.copyOf(cacheLine, exponent + 1); >> for (int i = oldLength; i < exponent + 1; i++) >> cacheLine[i] = cacheLine[i - 1].square(); >> >> if (exponent >= powerCache[radix].length) { // volatile read again >> BigInteger[][] pc = Arrays.copyOf(powerCache); >> pc[radix] = cacheLine; >> powerCache = pc; // volatile write, publish >> } >> return cacheLine[exponent]; >> }