Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c48c238

Browse filesBrowse files
committed
mybatis#101: Specify max size for pending creations
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
1 parent 05527aa commit c48c238
Copy full SHA for c48c238

File tree

Expand file treeCollapse file tree

1 file changed

+6
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-4
lines changed
Open diff view settings
Collapse file

‎src/main/java/org/apache/ibatis/executor/resultset/PendingConstructorCreation.java‎

Copy file name to clipboardExpand all lines: src/main/java/org/apache/ibatis/executor/resultset/PendingConstructorCreation.java
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ final class PendingConstructorCreation {
4444
private final Map<String, List<PendingConstructorCreation>> linkedCreationsByResultMapId;
4545

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

6971
// will be checked before we finally create the object) as we cannot reliably do that here
70-
return (Collection<Object>) objectFactory.create(constructorMapping.getJavaType());
72+
return (Collection<Object>) objectFactory.create(parameterType);
7173
});
7274
}
7375

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.