Memory optimization: Fewer ConcurrentHashMap.Segment instances
This commit is contained in:
@@ -101,7 +101,7 @@ public class LockBasedStorageManager implements StorageManager {
|
||||
@NotNull
|
||||
@Override
|
||||
public <K, V> MemoizedFunctionToNotNull<K, V> createMemoizedFunction(@NotNull Function1<? super K, ? extends V> compute) {
|
||||
return createMemoizedFunction(compute, new ConcurrentHashMap<K, Object>());
|
||||
return createMemoizedFunction(compute, LockBasedStorageManager.<K>createConcurrentHashMap());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -115,7 +115,13 @@ public class LockBasedStorageManager implements StorageManager {
|
||||
@NotNull
|
||||
@Override
|
||||
public <K, V> MemoizedFunctionToNullable<K, V> createMemoizedFunctionWithNullableValues(@NotNull Function1<? super K, ? extends V> compute) {
|
||||
return createMemoizedFunctionWithNullableValues(compute, new ConcurrentHashMap<K, Object>());
|
||||
return createMemoizedFunctionWithNullableValues(compute, LockBasedStorageManager.<K>createConcurrentHashMap());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static <K> ConcurrentMap<K, Object> createConcurrentHashMap() {
|
||||
// memory optimization: fewer segments and entries stored
|
||||
return new ConcurrentHashMap<K, Object>(3, 1, 2);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user