Skip to content

Commit a257d39

Browse files
committed
more efficient update
1 parent 6d148e5 commit a257d39

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

server/src/main/java/org/elasticsearch/repositories/ShardGenerations.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,18 +254,18 @@ public Builder put(IndexId indexId, int shardId, ShardGeneration generation) {
254254
return this;
255255
}
256256

257-
private Builder updateIfPresent(ShardGenerations shardGenerations) {
257+
private void updateIfPresent(ShardGenerations shardGenerations) {
258258
shardGenerations.shardGenerations.forEach((indexId, gens) -> {
259-
if (generations.containsKey(indexId)) {
259+
final Map<Integer, ShardGeneration> existingShardGens = generations.get(indexId);
260+
if (existingShardGens != null) {
260261
for (int i = 0; i < gens.size(); i++) {
261262
final ShardGeneration gen = gens.get(i);
262263
if (gen != null) {
263-
generations.get(indexId).put(i, gen);
264+
existingShardGens.put(i, gen);
264265
}
265266
}
266267
}
267268
});
268-
return this;
269269
}
270270

271271
private boolean noDuplicateIndicesWithSameName(IndexId newId) {

0 commit comments

Comments
 (0)