HHH-16430 Small optimisation in Dialect initializations

This commit is contained in:
Sanne Grinovero 2023-04-03 17:07:55 +01:00 committed by Sanne Grinovero
parent 845e9770d5
commit a5315c7e50
2 changed files with 251 additions and 250 deletions

View File

@ -610,9 +610,10 @@ public abstract class Dialect implements ConversionContext, TypeContributor, Fun
*/ */
protected void registerDefaultKeywords() { protected void registerDefaultKeywords() {
AnsiSqlKeywords keywords = new AnsiSqlKeywords(); AnsiSqlKeywords keywords = new AnsiSqlKeywords();
for ( String keyword : keywords.sql2003() ) { //Not using #registerKeyword as:
registerKeyword( keyword ); // # these are already lowercase
} // # better efficiency of addAll as it can pre-size the collections
sqlKeywords.addAll( keywords.sql2003() );
} }
/** /**

View File

@ -6,7 +6,7 @@
*/ */
package org.hibernate.engine.jdbc.env.spi; package org.hibernate.engine.jdbc.env.spi;
import java.util.Set; import java.util.List;
/** /**
* Maintains the set of ANSI SQL keywords * Maintains the set of ANSI SQL keywords
@ -15,253 +15,253 @@ import java.util.Set;
*/ */
public final class AnsiSqlKeywords { public final class AnsiSqlKeywords {
private final Set<String> keywordsSql2003; private final List<String> keywordsSql2003;
public AnsiSqlKeywords() { public AnsiSqlKeywords() {
this.keywordsSql2003 = Set.of( this.keywordsSql2003 = List.of(
"add", "add",
"all", "all",
"allocate", "allocate",
"alter", "alter",
"and", "and",
"any", "any",
"are", "are",
"array", "array",
"as", "as",
"asensitive", "asensitive",
"asymmetric", "asymmetric",
"at", "at",
"atomic", "atomic",
"authorization", "authorization",
"begin", "begin",
"between", "between",
"bigint", "bigint",
"blob", "blob",
"binary", "binary",
"both", "both",
"by", "by",
"call", "call",
"called", "called",
"cascaded", "cascaded",
"case", "case",
"cast", "cast",
"char", "char",
"character", "character",
"check", "check",
"clob", "clob",
"close", "close",
"collate", "collate",
"column", "column",
"commit", "commit",
"condition", "condition",
"connect", "connect",
"constraint", "constraint",
"continue", "continue",
"corresponding", "corresponding",
"create", "create",
"cross", "cross",
"cube", "cube",
"current", "current",
"current_date", "current_date",
"current_path", "current_path",
"current_role", "current_role",
"current_time", "current_time",
"current_timestamp", "current_timestamp",
"current_user", "current_user",
"cursor", "cursor",
"cycle", "cycle",
"date", "date",
"day", "day",
"deallocate", "deallocate",
"dec", "dec",
"decimal", "decimal",
"declare", "declare",
"default", "default",
"delete", "delete",
"deref", "deref",
"describe", "describe",
"deterministic", "deterministic",
"disconnect", "disconnect",
"distinct", "distinct",
"do", "do",
"double", "double",
"drop", "drop",
"dynamic", "dynamic",
"each", "each",
"element", "element",
"else", "else",
"elsif", "elsif",
"end", "end",
"escape", "escape",
"except", "except",
"exec", "exec",
"execute", "execute",
"exists", "exists",
"exit", "exit",
"external", "external",
"false", "false",
"fetch", "fetch",
"filter", "filter",
"float", "float",
"for", "for",
"foreign", "foreign",
"free", "free",
"from", "from",
"full", "full",
"function", "function",
"get", "get",
"global", "global",
"grant", "grant",
"group", "group",
"grouping", "grouping",
"handler", "handler",
"having", "having",
"hold", "hold",
"hour", "hour",
"identity", "identity",
"if", "if",
"immediate", "immediate",
"in", "in",
"indicator", "indicator",
"inner", "inner",
"inout", "inout",
"input", "input",
"insensitive", "insensitive",
"insert", "insert",
"int", "int",
"integer", "integer",
"intersect", "intersect",
"interval", "interval",
"into", "into",
"is", "is",
"iterate", "iterate",
"join", "join",
"language", "language",
"large", "large",
"lateral", "lateral",
"leading", "leading",
"leave", "leave",
"left", "left",
"like", "like",
"local", "local",
"localtime", "localtime",
"localtimestamp", "localtimestamp",
"loop", "loop",
"match", "match",
"member", "member",
"merge", "merge",
"method", "method",
"minute", "minute",
"modifies", "modifies",
"module", "module",
"month", "month",
"multiset", "multiset",
"national", "national",
"natural", "natural",
"nchar", "nchar",
"nclob", "nclob",
"new", "new",
"no", "no",
"none", "none",
"not", "not",
"null", "null",
"numeric", "numeric",
"of", "of",
"old", "old",
"on", "on",
"only", "only",
"open", "open",
"or", "or",
"order", "order",
"out", "out",
"outer", "outer",
"output", "output",
"over", "over",
"overlaps", "overlaps",
"parameter", "parameter",
"partition", "partition",
"precision", "precision",
"prepare", "prepare",
"primary", "primary",
"procedure", "procedure",
"range", "range",
"reads", "reads",
"real", "real",
"recursive", "recursive",
"ref", "ref",
"references", "references",
"referencing", "referencing",
"release", "release",
"repeat", "repeat",
"resignal", "resignal",
"result", "result",
"return", "return",
"returns", "returns",
"revoke", "revoke",
"right", "right",
"rollback", "rollback",
"rollup", "rollup",
"row", "row",
"rows", "rows",
"savepoint", "savepoint",
"scroll", "scroll",
"search", "search",
"second", "second",
"select", "select",
"sensitive", "sensitive",
"session_use", "session_use",
"set", "set",
"signal", "signal",
"similar", "similar",
"smallint", "smallint",
"some", "some",
"specific", "specific",
"specifictype", "specifictype",
"sql", "sql",
"sqlexception", "sqlexception",
"sqlstate", "sqlstate",
"sqlwarning", "sqlwarning",
"start", "start",
"static", "static",
"submultiset", "submultiset",
"symmetric", "symmetric",
"system", "system",
"system_user", "system_user",
"table", "table",
"tablesample", "tablesample",
"then", "then",
"time", "time",
"timestamp", "timestamp",
"timezone_hour", "timezone_hour",
"timezone_minute", "timezone_minute",
"to", "to",
"trailing", "trailing",
"translation", "translation",
"treat", "treat",
"trigger", "trigger",
"true", "true",
"undo", "undo",
"union", "union",
"unique", "unique",
"unknown", "unknown",
"unnest", "unnest",
"until", "until",
"update", "update",
"user", "user",
"using", "using",
"value", "value",
"values", "values",
"varchar", "varchar",
"varying", "varying",
"when", "when",
"whenever", "whenever",
"where", "where",
"while", "while",
"window", "window",
"with", "with",
"within", "within",
"without", "without",
"year"); "year");
} }
/** /**
@ -270,7 +270,7 @@ public final class AnsiSqlKeywords {
* *
* @return ANSI SQL:2003 keywords * @return ANSI SQL:2003 keywords
*/ */
public Set<String> sql2003() { public List<String> sql2003() {
return keywordsSql2003; return keywordsSql2003;
} }