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

Fix initial capacities of hash-based collections once again

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