Explorar el Código

HashMap init optimize when adding new ClusterNode to cluster node map (#465)

- reuse old map size to avoid rearrange and rehash the map
master
luoxiangnan Eric Zhao hace 6 años
padre
commit
f306a03090
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  1. +1
    -1
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/clusterbuilder/ClusterBuilderSlot.java

+ 1
- 1
sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/clusterbuilder/ClusterBuilderSlot.java Ver fichero

@@ -81,7 +81,7 @@ public class ClusterBuilderSlot extends AbstractLinkedProcessorSlot<DefaultNode>
if (clusterNode == null) {
// Create the cluster node.
clusterNode = Env.nodeBuilder.buildClusterNode();
HashMap<ResourceWrapper, ClusterNode> newMap = new HashMap<ResourceWrapper, ClusterNode>(16);
HashMap<ResourceWrapper, ClusterNode> newMap = new HashMap<ResourceWrapper, ClusterNode>(Math.max(clusterNodeMap.size(), 16));
newMap.putAll(clusterNodeMap);
newMap.put(node.getId(), clusterNode);



Cargando…
Cancelar
Guardar