HHH-13189 Optimise for less allocations as well
This commit is contained in:
parent
b32cacac71
commit
f383df13a7
|
@ -36,8 +36,8 @@ import org.hibernate.type.Type;
|
||||||
public class ParameterMetadataImpl implements ParameterMetadata {
|
public class ParameterMetadataImpl implements ParameterMetadata {
|
||||||
private final Map<Integer,OrdinalParameterDescriptor> ordinalDescriptorMap;
|
private final Map<Integer,OrdinalParameterDescriptor> ordinalDescriptorMap;
|
||||||
private final Map<String,NamedParameterDescriptor> namedDescriptorMap;
|
private final Map<String,NamedParameterDescriptor> namedDescriptorMap;
|
||||||
private final Set<OrdinalParameterDescriptor> ordinalDescriptorValueCache;
|
private final Collection<QueryParameter> ordinalDescriptorValueCache;
|
||||||
private final Set<NamedParameterDescriptor> namedDescriptorValueCache;
|
private final Collection<QueryParameter> namedDescriptorValueCache;
|
||||||
|
|
||||||
public ParameterMetadataImpl(
|
public ParameterMetadataImpl(
|
||||||
Map<Integer,OrdinalParameterDescriptor> ordinalDescriptorMap,
|
Map<Integer,OrdinalParameterDescriptor> ordinalDescriptorMap,
|
||||||
|
@ -47,13 +47,13 @@ public class ParameterMetadataImpl implements ParameterMetadata {
|
||||||
: Collections.unmodifiableMap( ordinalDescriptorMap );
|
: Collections.unmodifiableMap( ordinalDescriptorMap );
|
||||||
this.ordinalDescriptorValueCache = this.ordinalDescriptorMap.isEmpty()
|
this.ordinalDescriptorValueCache = this.ordinalDescriptorMap.isEmpty()
|
||||||
? Collections.emptySet()
|
? Collections.emptySet()
|
||||||
: Collections.unmodifiableSet(new HashSet<>(this.ordinalDescriptorMap.values()));
|
: Collections.unmodifiableCollection( this.ordinalDescriptorMap.values() );
|
||||||
this.namedDescriptorMap = namedDescriptorMap == null
|
this.namedDescriptorMap = namedDescriptorMap == null
|
||||||
? Collections.emptyMap()
|
? Collections.emptyMap()
|
||||||
: Collections.unmodifiableMap( namedDescriptorMap );
|
: Collections.unmodifiableMap( namedDescriptorMap );
|
||||||
this.namedDescriptorValueCache = this.namedDescriptorMap.isEmpty()
|
this.namedDescriptorValueCache = this.namedDescriptorMap.isEmpty()
|
||||||
? Collections.emptySet()
|
? Collections.emptySet()
|
||||||
: Collections.unmodifiableSet(new HashSet<>(this.namedDescriptorMap.values()));
|
: Collections.unmodifiableCollection( this.namedDescriptorMap.values() );
|
||||||
|
|
||||||
|
|
||||||
if (ordinalDescriptorMap != null && ! ordinalDescriptorMap.isEmpty() ) {
|
if (ordinalDescriptorMap != null && ! ordinalDescriptorMap.isEmpty() ) {
|
||||||
|
@ -87,15 +87,14 @@ public class ParameterMetadataImpl implements ParameterMetadata {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<QueryParameter> getPositionalParameters() {
|
public Collection<QueryParameter> getPositionalParameters() {
|
||||||
return Collections.unmodifiableCollection( ordinalDescriptorMap.values() );
|
return ordinalDescriptorValueCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<QueryParameter> getNamedParameters() {
|
public Collection<QueryParameter> getNamedParameters() {
|
||||||
return Collections.unmodifiableCollection( namedDescriptorMap.values() );
|
return namedDescriptorValueCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getParameterCount() {
|
public int getParameterCount() {
|
||||||
return ordinalDescriptorMap.size() + namedDescriptorMap.size();
|
return ordinalDescriptorMap.size() + namedDescriptorMap.size();
|
||||||
|
|
Loading…
Reference in New Issue