|
|
@@ -182,9 +182,13 @@ public class Cache<K,V> extends AbstractMap<K,V> {
|
|
|
final int maxsize;
|
|
|
|
|
|
CacheMap(int maxsize) {
|
|
|
- super( Math.round(maxsize / 0.75f)+2, 0.75f, true);
|
|
|
+ super( ic(maxsize), 0.75f, true);
|
|
|
this.maxsize = maxsize;
|
|
|
}
|
|
|
+
|
|
|
+ private static int ic(int maxsize) {
|
|
|
+ return ( maxsize == Integer.MAX_VALUE) ? 16 :Math.min(Math.round(maxsize / 0.75f)+2, 2048);
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
protected boolean removeEldestEntry(Entry<TK, Reference<TV>> eldest) {
|