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:
@@ -164,7 +164,7 @@ public class MessageHeaders implements Map<String, Object>, Serializable {
|
||||
* @param keysToIgnore the keys of the entries to ignore
|
||||
*/
|
||||
private MessageHeaders(MessageHeaders original, Set<String> keysToIgnore) {
|
||||
this.headers = new HashMap<>(original.headers.size() - keysToIgnore.size());
|
||||
this.headers = new HashMap<>(original.headers.size());
|
||||
original.headers.forEach((key, value) -> {
|
||||
if (!keysToIgnore.contains(key)) {
|
||||
this.headers.put(key, value);
|
||||
|
||||
@@ -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.
|
||||
@@ -38,7 +38,7 @@ import org.springframework.util.MultiValueMap;
|
||||
public abstract class AbstractSubscriptionRegistry implements SubscriptionRegistry {
|
||||
|
||||
private static final MultiValueMap<String, String> EMPTY_MAP =
|
||||
CollectionUtils.unmodifiableMultiValueMap(new LinkedMultiValueMap<>(0));
|
||||
CollectionUtils.unmodifiableMultiValueMap(new LinkedMultiValueMap<>());
|
||||
|
||||
protected final Log logger = SimpLogging.forLogName(getClass());
|
||||
|
||||
|
||||
@@ -317,7 +317,7 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
|
||||
if (handler == null) {
|
||||
return null;
|
||||
}
|
||||
Map<String, MessageHandler> subscriptions = new HashMap<>(1);
|
||||
Map<String, MessageHandler> subscriptions = new HashMap<>(4);
|
||||
String destination = getBrokerRegistry().getUserDestinationBroadcast();
|
||||
if (destination != null) {
|
||||
subscriptions.put(destination, userDestinationMessageHandler());
|
||||
|
||||
@@ -545,7 +545,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati
|
||||
private class SessionLookup {
|
||||
|
||||
public Map<String, SimpSession> findSessions(String userName) {
|
||||
Map<String, SimpSession> map = new HashMap<>(1);
|
||||
Map<String, SimpSession> map = new HashMap<>(4);
|
||||
SimpUser user = localRegistry.getUser(userName);
|
||||
if (user != null) {
|
||||
for (SimpSession session : user.getSessions()) {
|
||||
|
||||
Reference in New Issue
Block a user