Skip to content

Commit 488a05b

Browse files
committed
newMapWithExpectedSize
1 parent bd06c7e commit 488a05b

File tree

1 file changed

+2
-1
lines changed
  • server/src/main/java/org/elasticsearch/index/store

1 file changed

+2
-1
lines changed

server/src/main/java/org/elasticsearch/index/store/Store.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.elasticsearch.common.lucene.store.InputStreamIndexInput;
5353
import org.elasticsearch.common.settings.Setting;
5454
import org.elasticsearch.common.settings.Setting.Property;
55+
import org.elasticsearch.common.util.Maps;
5556
import org.elasticsearch.core.AbstractRefCounted;
5657
import org.elasticsearch.core.Nullable;
5758
import org.elasticsearch.core.RefCounted;
@@ -780,7 +781,7 @@ public MetadataSnapshot(Map<String, StoreFileMetadata> metadata, Map<String, Str
780781

781782
public static MetadataSnapshot readFrom(StreamInput in) throws IOException {
782783
final int metadataSize = in.readVInt();
783-
final Map<String, StoreFileMetadata> metadata = metadataSize == 0 ? emptyMap() : new HashMap<>();
784+
final Map<String, StoreFileMetadata> metadata = metadataSize == 0 ? emptyMap() : Maps.newMapWithExpectedSize(metadataSize);
784785
for (int i = 0; i < metadataSize; i++) {
785786
final var storeFileMetadata = new StoreFileMetadata(in);
786787
metadata.put(storeFileMetadata.name(), storeFileMetadata);

0 commit comments

Comments
 (0)