Replace several magic numbers. (#10094)
Motivation: Magic numbers seem hard to read or understand. Modification: Replace several magic numbers with named constants. Result: Improve readability and make it easier to maintain.
This commit is contained in:
parent
ab14e0b583
commit
217365dd65
@ -44,6 +44,8 @@ public final class InternalThreadLocalMap extends UnpaddedInternalThreadLocalMap
|
||||
private static final int DEFAULT_ARRAY_LIST_INITIAL_CAPACITY = 8;
|
||||
private static final int STRING_BUILDER_INITIAL_SIZE;
|
||||
private static final int STRING_BUILDER_MAX_SIZE;
|
||||
private static final int HANDLER_SHARABLE_CACHE_INITIAL_CAPACITY = 4;
|
||||
private static final int INDEXED_VARIABLE_TABLE_INITIAL_SIZE = 32;
|
||||
|
||||
public static final Object UNSET = new Object();
|
||||
|
||||
@ -128,7 +130,7 @@ public final class InternalThreadLocalMap extends UnpaddedInternalThreadLocalMap
|
||||
}
|
||||
|
||||
private static Object[] newIndexedVariableTable() {
|
||||
Object[] array = new Object[32];
|
||||
Object[] array = new Object[INDEXED_VARIABLE_TABLE_INITIAL_SIZE];
|
||||
Arrays.fill(array, UNSET);
|
||||
return array;
|
||||
}
|
||||
@ -259,7 +261,7 @@ public final class InternalThreadLocalMap extends UnpaddedInternalThreadLocalMap
|
||||
Map<Class<?>, Boolean> cache = handlerSharableCache;
|
||||
if (cache == null) {
|
||||
// Start with small capacity to keep memory overhead as low as possible.
|
||||
handlerSharableCache = cache = new WeakHashMap<>(4);
|
||||
handlerSharableCache = cache = new WeakHashMap<>(HANDLER_SHARABLE_CACHE_INITIAL_CAPACITY);
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user