HHH-13496 Some collection constructors could benefit from size hinting
This commit is contained in:
parent
18e8c04d4d
commit
35b67bd00e
|
@ -108,8 +108,7 @@ public class BulkOperationCleanupAction implements Executable, Serializable {
|
|||
*/
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public BulkOperationCleanupAction(SharedSessionContractImplementor session, Set tableSpaces) {
|
||||
final LinkedHashSet<String> spacesList = new LinkedHashSet<>();
|
||||
spacesList.addAll( tableSpaces );
|
||||
final LinkedHashSet<String> spacesList = new LinkedHashSet<>( tableSpaces );
|
||||
|
||||
final SessionFactoryImplementor factory = session.getFactory();
|
||||
final MetamodelImplementor metamodel = factory.getMetamodel();
|
||||
|
|
|
@ -1691,8 +1691,7 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector
|
|||
|
||||
ArrayList<CopyIdentifierComponentSecondPass> sorted =
|
||||
new ArrayList<>( copyIdentifierComponentSecondPasList.size() );
|
||||
Set<CopyIdentifierComponentSecondPass> toSort = new HashSet<>();
|
||||
toSort.addAll( copyIdentifierComponentSecondPasList );
|
||||
Set<CopyIdentifierComponentSecondPass> toSort = new HashSet<>( copyIdentifierComponentSecondPasList );
|
||||
topologicalSort( sorted, toSort );
|
||||
copyIdentifierComponentSecondPasList = sorted;
|
||||
}
|
||||
|
|
|
@ -33,8 +33,7 @@ public class CommaSeparatedStringHelper {
|
|||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
HashSet<String> set = new HashSet<String>();
|
||||
set.addAll( x );
|
||||
HashSet<String> set = new HashSet<String>( x );
|
||||
if ( values != null && !values.isEmpty() ) {
|
||||
Collections.addAll( set, values.split( "\\s*,\\s*" ) );
|
||||
}
|
||||
|
|
|
@ -278,8 +278,7 @@ public class StandardServiceRegistryBuilder {
|
|||
applyServiceContributingIntegrators();
|
||||
applyServiceContributors();
|
||||
|
||||
final Map settingsCopy = new HashMap();
|
||||
settingsCopy.putAll( settings );
|
||||
final Map settingsCopy = new HashMap( settings );
|
||||
settingsCopy.put( org.hibernate.boot.cfgxml.spi.CfgXmlAccessService.LOADED_CONFIG_KEY, aggregatedCfgXml );
|
||||
ConfigurationHelper.resolvePlaceHolders( settingsCopy );
|
||||
|
||||
|
|
|
@ -105,9 +105,7 @@ public class ClassLoaderServiceImpl implements ClassLoaderService {
|
|||
|
||||
final Collection<ClassLoader> classLoaders = (Collection<ClassLoader>) configValues.get( AvailableSettings.CLASSLOADERS );
|
||||
if ( classLoaders != null ) {
|
||||
for ( ClassLoader classLoader : classLoaders ) {
|
||||
providedClassLoaders.add( classLoader );
|
||||
}
|
||||
providedClassLoaders.addAll( classLoaders );
|
||||
}
|
||||
|
||||
addIfSet( providedClassLoaders, AvailableSettings.APP_CLASSLOADER, configValues );
|
||||
|
|
|
@ -2808,8 +2808,7 @@ public final class AnnotationBinder {
|
|||
buildingContext.getMetadataCollector().addSecondPass( secondPass );
|
||||
}
|
||||
else {
|
||||
Map<String, IdentifierGeneratorDefinition> localGenerators = new HashMap<>();
|
||||
localGenerators.putAll( buildGenerators( property, buildingContext ) );
|
||||
Map<String, IdentifierGeneratorDefinition> localGenerators = new HashMap<>( buildGenerators( property, buildingContext ) );
|
||||
BinderHelper.makeIdGenerator(
|
||||
(SimpleValue) comp.getProperty( property.getName() ).getValue(),
|
||||
property,
|
||||
|
|
|
@ -74,10 +74,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
bag = (List) coll;
|
||||
}
|
||||
else {
|
||||
bag = new ArrayList();
|
||||
for ( Object element : coll ) {
|
||||
bag.add( element );
|
||||
}
|
||||
bag = new ArrayList( coll );
|
||||
}
|
||||
setInitialized();
|
||||
setDirectlyAccessible( true );
|
||||
|
|
|
@ -80,10 +80,7 @@ public class PersistentIdentifierBag extends AbstractPersistentCollection implem
|
|||
values = (List<Object>) coll;
|
||||
}
|
||||
else {
|
||||
values = new ArrayList<>();
|
||||
for ( Object element : coll ) {
|
||||
values.add( element );
|
||||
}
|
||||
values = new ArrayList<>( coll );
|
||||
}
|
||||
setInitialized();
|
||||
setDirectlyAccessible( true );
|
||||
|
|
|
@ -211,8 +211,7 @@ public class ExtractedDatabaseMetaDataImpl implements ExtractedDatabaseMetaData
|
|||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
final Set<String> keywordSet = new HashSet<String>();
|
||||
keywordSet.addAll( Arrays.asList( extraKeywordsString.split( "\\s*,\\s*" ) ) );
|
||||
final Set<String> keywordSet = new HashSet<String>( Arrays.asList( extraKeywordsString.split( "\\s*,\\s*" ) ) );
|
||||
return keywordSet;
|
||||
}
|
||||
|
||||
|
|
|
@ -416,8 +416,7 @@ public class QueryPlanCache implements Serializable {
|
|||
this.filterNames = Collections.emptySet();
|
||||
}
|
||||
else {
|
||||
final Set<String> tmp = new HashSet<String>();
|
||||
tmp.addAll( enabledFilters.keySet() );
|
||||
final Set<String> tmp = new HashSet<String>( enabledFilters.keySet() );
|
||||
this.filterNames = Collections.unmodifiableSet( tmp );
|
||||
|
||||
}
|
||||
|
|
|
@ -38,8 +38,7 @@ public class NativeSQLQuerySpecification {
|
|||
this.querySpaces = Collections.EMPTY_SET;
|
||||
}
|
||||
else {
|
||||
Set tmp = new HashSet();
|
||||
tmp.addAll( querySpaces );
|
||||
Set tmp = new HashSet( querySpaces );
|
||||
this.querySpaces = Collections.unmodifiableSet( tmp );
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,7 @@ public class SQLStateConversionDelegate extends AbstractSQLExceptionConversionDe
|
|||
|
||||
private static final Set<String> SQL_GRAMMAR_CATEGORIES = buildGrammarCategories();
|
||||
private static Set<String> buildGrammarCategories() {
|
||||
HashSet<String> categories = new HashSet<String>();
|
||||
categories.addAll(
|
||||
HashSet<String> categories = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"07", // "dynamic SQL error"
|
||||
"20",
|
||||
|
@ -57,8 +56,7 @@ public class SQLStateConversionDelegate extends AbstractSQLExceptionConversionDe
|
|||
|
||||
private static final Set DATA_CATEGORIES = buildDataCategories();
|
||||
private static Set<String> buildDataCategories() {
|
||||
HashSet<String> categories = new HashSet<String>();
|
||||
categories.addAll(
|
||||
HashSet<String> categories = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"21", // "cardinality violation"
|
||||
"22" // "data exception"
|
||||
|
@ -69,8 +67,7 @@ public class SQLStateConversionDelegate extends AbstractSQLExceptionConversionDe
|
|||
|
||||
private static final Set INTEGRITY_VIOLATION_CATEGORIES = buildContraintCategories();
|
||||
private static Set<String> buildContraintCategories() {
|
||||
HashSet<String> categories = new HashSet<String>();
|
||||
categories.addAll(
|
||||
HashSet<String> categories = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"23", // "integrity constraint violation"
|
||||
"27", // "triggered data change violation"
|
||||
|
|
|
@ -440,11 +440,10 @@ public class BoundedConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
|||
|
||||
@Override
|
||||
public Set<HashEntry<K, V>> execute() {
|
||||
Set<HashEntry<K, V>> evictedCopy = new HashSet<HashEntry<K, V>>();
|
||||
Set<HashEntry<K, V>> evictedCopy = new HashSet<HashEntry<K, V>>( evicted );
|
||||
for ( HashEntry<K, V> e : accessQueue ) {
|
||||
put( e, e.value );
|
||||
}
|
||||
evictedCopy.addAll( evicted );
|
||||
accessQueue.clear();
|
||||
evicted.clear();
|
||||
return evictedCopy;
|
||||
|
@ -454,8 +453,7 @@ public class BoundedConcurrentHashMap<K, V> extends AbstractMap<K, V>
|
|||
public Set<HashEntry<K, V>> onEntryMiss(HashEntry<K, V> e) {
|
||||
put( e, e.value );
|
||||
if ( !evicted.isEmpty() ) {
|
||||
Set<HashEntry<K, V>> evictedCopy = new HashSet<HashEntry<K, V>>();
|
||||
evictedCopy.addAll( evicted );
|
||||
Set<HashEntry<K, V>> evictedCopy = new HashSet<HashEntry<K, V>>( evicted );
|
||||
evicted.clear();
|
||||
return evictedCopy;
|
||||
}
|
||||
|
|
|
@ -64,8 +64,7 @@ public abstract class AbstractEntityJoinWalker extends JoinWalker {
|
|||
final LockOptions lockOptions,
|
||||
final AssociationInitCallback callback) throws MappingException {
|
||||
walkEntityTree( persister, getAlias() );
|
||||
List allAssociations = new ArrayList();
|
||||
allAssociations.addAll( associations );
|
||||
List allAssociations = new ArrayList( associations );
|
||||
allAssociations.add( OuterJoinableAssociation.createRoot( persister.getEntityType(), alias, getFactory() ) );
|
||||
initPersisters( allAssociations, lockOptions, callback );
|
||||
initStatementString( whereString, orderByString, lockOptions );
|
||||
|
|
|
@ -51,11 +51,10 @@ public class BasicCollectionJoinWalker extends CollectionJoinWalker {
|
|||
|
||||
walkCollectionTree(collectionPersister, alias);
|
||||
|
||||
List allAssociations = new ArrayList();
|
||||
allAssociations.addAll(associations);
|
||||
List allAssociations = new ArrayList( associations );
|
||||
allAssociations.add( OuterJoinableAssociation.createRoot( collectionPersister.getCollectionType(), alias, getFactory() ) );
|
||||
initPersisters(allAssociations, LockMode.NONE);
|
||||
initStatementString(alias, batchSize, subquery);
|
||||
initPersisters( allAssociations, LockMode.NONE );
|
||||
initStatementString( alias, batchSize, subquery );
|
||||
}
|
||||
|
||||
private void initStatementString(
|
||||
|
|
|
@ -58,8 +58,7 @@ public class OneToManyJoinWalker extends CollectionJoinWalker {
|
|||
|
||||
walkEntityTree( elementPersister, alias );
|
||||
|
||||
List allAssociations = new ArrayList();
|
||||
allAssociations.addAll( associations );
|
||||
List allAssociations = new ArrayList( associations );
|
||||
allAssociations.add(
|
||||
OuterJoinableAssociation.createRoot(
|
||||
oneToManyPersister.getCollectionType(),
|
||||
|
|
|
@ -255,9 +255,7 @@ public class SchemaExport {
|
|||
Metadata metadata,
|
||||
ServiceRegistry serviceRegistry,
|
||||
TargetDescriptor targetDescriptor) {
|
||||
Map config = new HashMap();
|
||||
config.putAll( serviceRegistry.getService( ConfigurationService.class ).getSettings() );
|
||||
|
||||
Map config = new HashMap( serviceRegistry.getService( ConfigurationService.class ).getSettings() );
|
||||
config.put( AvailableSettings.HBM2DDL_DELIMITER, delimiter );
|
||||
config.put( AvailableSettings.FORMAT_SQL, format );
|
||||
config.put( AvailableSettings.HBM2DDL_IMPORT_FILES, importFiles );
|
||||
|
|
|
@ -72,8 +72,7 @@ public class SchemaUpdate {
|
|||
exceptions.clear();
|
||||
LOG.runningHbm2ddlSchemaUpdate();
|
||||
|
||||
Map config = new HashMap();
|
||||
config.putAll( serviceRegistry.getService( ConfigurationService.class ).getSettings() );
|
||||
Map config = new HashMap( serviceRegistry.getService( ConfigurationService.class ).getSettings() );
|
||||
config.put( AvailableSettings.HBM2DDL_DELIMITER, delimiter );
|
||||
config.put( AvailableSettings.FORMAT_SQL, format );
|
||||
|
||||
|
|
|
@ -52,8 +52,7 @@ public class SchemaValidator {
|
|||
public void validate(Metadata metadata, ServiceRegistry serviceRegistry) {
|
||||
LOG.runningSchemaValidator();
|
||||
|
||||
Map config = new HashMap();
|
||||
config.putAll( serviceRegistry.getService( ConfigurationService.class ).getSettings() );
|
||||
Map config = new HashMap( serviceRegistry.getService( ConfigurationService.class ).getSettings() );
|
||||
|
||||
final SchemaManagementTool tool = serviceRegistry.getService( SchemaManagementTool.class );
|
||||
|
||||
|
|
Loading…
Reference in New Issue