Skip unrelated subtrees during config alias normalization (#50354)

Return a clone immediately when the current path is not a prefix of any
registered legacy config key. This avoids recursively visiting unrelated
subtrees while preserving alias normalization along matching paths.

GitOrigin-RevId: 1c7e62898e12ab3f468b978f865805989914ac44
This commit is contained in:
Brent Traut
2026-10-02 16:37:30 +00:00
committed by copyberry
parent 9d2b60303e
commit f4e18a95bb
+10
View File
@@ -61,6 +61,16 @@ pub(crate) fn normalize_key_aliases(value: &TomlValue) -> TomlValue {
}
fn normalize_key_aliases_at_path(value: &TomlValue, path: &[String]) -> TomlValue {
// Alias normalization cannot affect subtrees outside the registered legacy paths.
if !CONFIG_KEY_ALIASES.iter().any(|alias| {
alias
.legacy
.get(..path.len())
.is_some_and(|prefix| path.iter().map(String::as_str).eq(prefix.iter().copied()))
}) {
return value.clone();
}
match value {
TomlValue::Table(table) => {
let mut normalized = TomlMap::new();