提交 bef66efc authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix initial capacities of hash-based collections once again

上级 6353be85
......@@ -6,7 +6,6 @@
package org.h2.engine;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
......@@ -91,15 +90,14 @@ public class ConnectionInfo implements Cloneable {
}
static {
ArrayList<String> list = SetTypes.getTypes();
String[] connectionTime = { "ACCESS_MODE_DATA", "AUTOCOMMIT", "CIPHER",
"CREATE", "CACHE_TYPE", "FILE_LOCK", "IGNORE_UNKNOWN_SETTINGS",
"IFEXISTS", "INIT", "PASSWORD", "RECOVER", "RECOVER_TEST",
"USER", "AUTO_SERVER", "AUTO_SERVER_PORT", "NO_UPGRADE",
"AUTO_RECONNECT", "OPEN_NEW", "PAGE_SIZE", "PASSWORD_HASH", "JMX",
"SCOPE_GENERATED_KEYS" };
HashSet<String> set = new HashSet<>(list.size() + connectionTime.length);
set.addAll(list);
HashSet<String> set = new HashSet<>(128);
set.addAll(SetTypes.getTypes());
for (String key : connectionTime) {
if (!set.add(key) && SysProperties.CHECK) {
DbException.throwInternalError(key);
......
......@@ -136,7 +136,7 @@ public class Aggregate extends Expression {
ARRAY_AGG
}
private static final HashMap<String, AggregateType> AGGREGATES = new HashMap<>(26);
private static final HashMap<String, AggregateType> AGGREGATES = new HashMap<>(64);
private final AggregateType type;
private final Select select;
......
......@@ -1667,7 +1667,7 @@ public class JdbcCallableStatement extends JdbcPreparedStatement implements
if (namedParameters == null) {
ResultSetMetaData meta = getCheckedMetaData();
int columnCount = meta.getColumnCount();
HashMap<String, Integer> map = new HashMap<>(columnCount);
HashMap<String, Integer> map = new HashMap<>();
for (int i = 1; i <= columnCount; i++) {
map.put(meta.getColumnLabel(i), i);
}
......
......@@ -3119,7 +3119,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet, JdbcResultS
if (columnCount >= 3) {
// use a hash table if more than 2 columns
if (columnLabelMap == null) {
HashMap<String, Integer> map = new HashMap<>(columnCount);
HashMap<String, Integer> map = new HashMap<>();
// column labels have higher priority
for (int i = 0; i < columnCount; i++) {
String c = StringUtils.toUpperEnglish(result.getAlias(i));
......
......@@ -94,7 +94,7 @@ public class ObjectDataType implements DataType {
Float.class, Double.class, BigDecimal.class, String.class,
UUID.class, Date.class };
private static final HashMap<Class<?>, Integer> COMMON_CLASSES_MAP = new HashMap<>(COMMON_CLASSES.length);
private static final HashMap<Class<?>, Integer> COMMON_CLASSES_MAP = new HashMap<>(32);
private AutoDetectDataType last = new StringType(this);
......
......@@ -198,7 +198,7 @@ class WebSession {
* @return a map containing the session meta data
*/
HashMap<String, Object> getInfo() {
HashMap<String, Object> m = new HashMap<>(map.size() + 5);
HashMap<String, Object> m = new HashMap<>();
m.putAll(map);
m.put("lastAccess", new Timestamp(lastAccess).toString());
try {
......
......@@ -1076,7 +1076,7 @@ public class TableFilter implements ColumnResolver {
if (count != derivedColumnNames.size()) {
throw DbException.get(ErrorCode.COLUMN_COUNT_DOES_NOT_MATCH);
}
HashMap<Column, String> map = new HashMap<>(count);
HashMap<Column, String> map = new HashMap<>();
for (int i = 0; i < count; i++) {
String alias = derivedColumnNames.get(i);
for (int j = 0; j < i; j++) {
......
......@@ -619,8 +619,7 @@ class ToDateTokenizer {
private static final List<FormatTokenEnum> EMPTY_LIST = Collections
.emptyList();
private static final Map<Character, List<FormatTokenEnum>> CACHE = new HashMap<>(
FormatTokenEnum.values().length);
private static final Map<Character, List<FormatTokenEnum>> CACHE = new HashMap<>(64);
private final ToDateParslet toDateParslet;
private final Pattern patternToUse;
......
......@@ -66,8 +66,8 @@ public class DataType {
* when clearing references.
*/
private static final ArrayList<DataType> TYPES = new ArrayList<>(96);
private static final HashMap<String, DataType> TYPES_BY_NAME = new HashMap<>(96);
private static final HashMap<Integer, DataType> TYPES_BY_VALUE_TYPE = new HashMap<>(48);
private static final HashMap<String, DataType> TYPES_BY_NAME = new HashMap<>(128);
private static final HashMap<Integer, DataType> TYPES_BY_VALUE_TYPE = new HashMap<>(64);
/**
* The value type of this data type.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论