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:
@@ -410,7 +410,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
|
||||
Object cacheValue;
|
||||
Object returnValue;
|
||||
|
||||
if (cacheHit != null && cachePutRequests.isEmpty() && !hasCachePut(contexts)) {
|
||||
if (cacheHit != null && !hasCachePut(contexts)) {
|
||||
// If there are no put requests, just use the cache hit
|
||||
cacheValue = cacheHit.get();
|
||||
returnValue = wrapCacheValue(method, cacheValue);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -230,17 +230,21 @@ public class ConcurrentTaskExecutor implements AsyncListenableTaskExecutor, Sche
|
||||
protected static class ManagedTaskBuilder {
|
||||
|
||||
public static Runnable buildManagedTask(Runnable task, String identityName) {
|
||||
Map<String, String> properties = new HashMap<>(2);
|
||||
Map<String, String> properties;
|
||||
if (task instanceof SchedulingAwareRunnable) {
|
||||
properties = new HashMap<>(4);
|
||||
properties.put(ManagedTask.LONGRUNNING_HINT,
|
||||
Boolean.toString(((SchedulingAwareRunnable) task).isLongLived()));
|
||||
}
|
||||
else {
|
||||
properties = new HashMap<>(2);
|
||||
}
|
||||
properties.put(ManagedTask.IDENTITY_NAME, identityName);
|
||||
return ManagedExecutors.managedTask(task, properties, null);
|
||||
}
|
||||
|
||||
public static <T> Callable<T> buildManagedTask(Callable<T> task, String identityName) {
|
||||
Map<String, String> properties = new HashMap<>(1);
|
||||
Map<String, String> properties = new HashMap<>(2);
|
||||
properties.put(ManagedTask.IDENTITY_NAME, identityName);
|
||||
return ManagedExecutors.managedTask(task, properties, null);
|
||||
}
|
||||
|
||||
@@ -52,9 +52,9 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
|
||||
|
||||
private final List<ObjectError> errors = new LinkedList<>();
|
||||
|
||||
private final Map<String, Class<?>> fieldTypes = new HashMap<>(0);
|
||||
private final Map<String, Class<?>> fieldTypes = new HashMap<>();
|
||||
|
||||
private final Map<String, Object> fieldValues = new HashMap<>(0);
|
||||
private final Map<String, Object> fieldValues = new HashMap<>();
|
||||
|
||||
private final Set<String> suppressedFields = new HashSet<>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user