Skip to content

Commit 1d17ce6

Browse files
authored
Avoid redundantly copying a map in Settings builder (#135187)
When putting an existing `Settings` object into a `Settings.Builder`, we currently check if there are any legacy list setting keys (by checking if there's one key ending in `.0`). The value of doing that there in addition to doing it in the final `build()` method seems to be that legacy settings can be overriden by subsequent calls to the same builder, rather than the legacy settings overriding others at the end. Instead of copying the existing settings' map to a temporary map, we can put the keys directly into the builder's map and perform the legacy settings check there.
1 parent b04fe02 commit 1d17ce6

File tree

1 file changed

+2
-3
lines changed
  • server/src/main/java/org/elasticsearch/common/settings

1 file changed

+2
-3
lines changed

server/src/main/java/org/elasticsearch/common/settings/Settings.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,9 +1191,8 @@ public Builder put(Settings settings) {
11911191
* @param copySecureSettings if <code>true</code> all settings including secure settings are copied.
11921192
*/
11931193
public Builder put(Settings settings, boolean copySecureSettings) {
1194-
Map<String, Object> settingsMap = new HashMap<>(settings.settings);
1195-
processLegacyLists(settingsMap);
1196-
map.putAll(settingsMap);
1194+
map.putAll(settings.settings);
1195+
processLegacyLists(map);
11971196
if (copySecureSettings && settings.getSecureSettings() != null) {
11981197
setSecureSettings(settings.getSecureSettings());
11991198
}

0 commit comments

Comments
 (0)