提交 0196cf90 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Specify initial size of HashSet in ConnectionInfo

上级 087f7a18
...@@ -28,7 +28,7 @@ import org.h2.util.Utils; ...@@ -28,7 +28,7 @@ import org.h2.util.Utils;
* Encapsulates the connection settings, including user name and password. * Encapsulates the connection settings, including user name and password.
*/ */
public class ConnectionInfo implements Cloneable { public class ConnectionInfo implements Cloneable {
private static final HashSet<String> KNOWN_SETTINGS = New.hashSet(); private static final HashSet<String> KNOWN_SETTINGS;
private Properties prop = new Properties(); private Properties prop = new Properties();
private String originalURL; private String originalURL;
...@@ -93,18 +93,19 @@ public class ConnectionInfo implements Cloneable { ...@@ -93,18 +93,19 @@ public class ConnectionInfo implements Cloneable {
static { static {
ArrayList<String> list = SetTypes.getTypes(); ArrayList<String> list = SetTypes.getTypes();
HashSet<String> set = KNOWN_SETTINGS;
set.addAll(list);
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" };
HashSet<String> set = new HashSet<>(list.size() + connectionTime.length);
set.addAll(list);
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);
} }
} }
KNOWN_SETTINGS = set;
} }
private static boolean isKnownSetting(String s) { private static boolean isKnownSetting(String s) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论