提交 87817179 authored 作者: LaughingMan's avatar LaughingMan

Merge if and catch block

上级 7d8aee68
......@@ -51,16 +51,17 @@ public class CacheLRU implements Cache {
this.writer = writer;
this.fifo = fifo;
this.setMaxMemory(maxMemoryKb);
long tmpLen;
try {
tmpLen = MathUtils.nextPowerOf2(maxMemory / 64);
// Since setMaxMemory() ensures that maxMemory is >=0,
// we don't have to worry about an underflow.
long tmpLen = maxMemory / 64;
if (tmpLen > Integer.MAX_VALUE) {
throw new IllegalArgumentException();
}
this.len = MathUtils.nextPowerOf2((int) tmpLen);
} catch (IllegalArgumentException e) {
throw new IllegalStateException("This much cache memory is not supported: " + maxMemoryKb + "kb", e);
}
if (tmpLen > Integer.MAX_VALUE) {
throw new IllegalStateException("do not support this much cache memory: " + maxMemoryKb + "kb");
}
this.len = (int) tmpLen;
this.mask = len - 1;
clear();
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论