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() {
AnsiSqlKeywords keywords = new AnsiSqlKeywords();
for ( String keyword : keywords.sql2003() ) {
registerKeyword( keyword );
}
//Not using #registerKeyword as:
// # 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;
import java.util.Set;
import java.util.List;
/**
* Maintains the set of ANSI SQL keywords
@ -15,10 +15,10 @@ import java.util.Set;
*/
public final class AnsiSqlKeywords {
private final Set<String> keywordsSql2003;
private final List<String> keywordsSql2003;
public AnsiSqlKeywords() {
this.keywordsSql2003 = Set.of(
this.keywordsSql2003 = List.of(
"add",
"all",
"allocate",
@ -270,7 +270,7 @@ public final class AnsiSqlKeywords {
*
* @return ANSI SQL:2003 keywords
*/
public Set<String> sql2003() {
public List<String> sql2003() {
return keywordsSql2003;
}