Initialize pre-filled HashMaps with large enough capacity

Empty Maps are preferably initialized without capacity (not initializing them at all or lazily initializing with default capacity when needed).

Issue: SPR-17105
This commit is contained in:
Juergen Hoeller
2018-07-30 22:07:31 +02:00
parent 457d586859
commit 4a147d26fc
19 changed files with 38 additions and 41 deletions

View File

@@ -465,7 +465,7 @@ public abstract class AbstractJdbcInsert {
if (keyQuery.toUpperCase().startsWith("RETURNING")) {
Long key = getJdbcTemplate().queryForObject(
getInsertString() + " " + keyQuery, values.toArray(), Long.class);
Map<String, Object> keys = new HashMap<>(1);
Map<String, Object> keys = new HashMap<>(2);
keys.put(getGeneratedKeyNames()[0], key);
keyHolder.getKeyList().add(keys);
}
@@ -484,7 +484,7 @@ public abstract class AbstractJdbcInsert {
//Get the key
Statement keyStmt = null;
ResultSet rs = null;
Map<String, Object> keys = new HashMap<>(1);
Map<String, Object> keys = new HashMap<>(2);
try {
keyStmt = con.createStatement();
rs = keyStmt.executeQuery(keyQuery);