Skip to content

Commit

Permalink
#101: Specify max size for pending creations
Browse files Browse the repository at this point in the history
Theoretically, if all of our types are nested mappings, a resize would occur, however we will almost always not have this due to an idArg being necessary, and allocating the default of 16 elements is too much
  • Loading branch information
epochcoder committed Mar 9, 2024
1 parent 05527aa commit c48c238
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ final class PendingConstructorCreation {
private final Map<String, List<PendingConstructorCreation>> linkedCreationsByResultMapId;

PendingConstructorCreation(Class<?> resultType, List<Class<?>> types, List<Object> args) {
this.linkedCollectionMetaInfo = new HashMap<>();
this.linkedCollectionsByResultMapId = new HashMap<>();
this.linkedCreationsByResultMapId = new HashMap<>();
// since all our keys are based on result map id, we know we will never go over args size
final int maxSize = types.size();
this.linkedCollectionMetaInfo = new HashMap<>(maxSize);
this.linkedCollectionsByResultMapId = new HashMap<>(maxSize);
this.linkedCreationsByResultMapId = new HashMap<>(maxSize);
this.resultType = resultType;
this.constructorArgTypes = types;
this.constructorArgs = args;
Expand All @@ -67,7 +69,7 @@ Collection<Object> initializeCollectionForResultMapping(ObjectFactory objectFact
linkedCollectionMetaInfo.put(index, new PendingCreationMetaInfo(resultMap.getType(), resultMapId));

// will be checked before we finally create the object) as we cannot reliably do that here
return (Collection<Object>) objectFactory.create(constructorMapping.getJavaType());
return (Collection<Object>) objectFactory.create(parameterType);
});
}

Expand Down

0 comments on commit c48c238

Please sign in to comment.