Repository: microsoft/terminal
File: src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp (C++)

Code before:
            profilesList.append(prof->ToJson());
        }
    }
    profiles[JsonKey(ProfilesListKey)] = profilesList;
    json[JsonKey(ProfilesKey)] = profiles;

    // TODO GH#8100:
    // "schemes" will be an accumulation of _all_ the color schemes
    // including all of the ones from defaults.json
    Json::Value schemes{ Json::ValueType::arrayValue };
    for (const auto& entry : _globals->ColorSchemes())
    {
        const auto scheme{ winrt::get_self<ColorScheme>(entry.Value()) };
        schemes.append(scheme->ToJson());
    }
    json[JsonKey(SchemesKey)] = schemes;

    Json::Value themes{ Json::ValueType::arrayValue };
    for (const auto& entry : _globals->Themes())
    {
        // Ignore the built in themes, when serializing the themes back out. We
        // don't want to re-include them in the user settings file.
        const auto theme{ winrt::get_self<Theme>(entry.Value()) };
        const auto& name{ theme->Name() };
        if (name == systemThemeName || name == lightThemeName || name == darkThemeName ||
            name == legacySystemThemeName || name == legacyLightThemeName || name == legacyDarkThemeName)
        {
            continue;
        }
        themes.append(theme->ToJson());
    }
    json[JsonKey(ThemesKey)] = themes;

    return json;
}

// Method Description:
// - Resolves the "defaultProfile", which can be a profile name, to a GUID
//   and stores it back to the globals.
void CascadiaSettings::_resolveDefaultProfile() const
{
    if (const auto unparsedDefaultProfile = _globals->UnparsedDefaultProfile(); !unparsedDefaultProfile.empty())
    {
        if (const auto profile = GetProfileByName(unparsedDefaultProfile))
        {
            _globals->DefaultProfile(profile.Guid());
            return;
        }

        _warnings.Append(SettingsLoadWarnings::MissingDefaultProfile);
    }

Review comment (suggestion):
A loop would be a good fit here:
```cpp
static constexpr std::array builtinThemes{
    systemThemeName,
    lightThemeName,
    darkThemeName,
    legacySystemThemeName,
    legacyLightThemeName,
    legacyDarkThemeName,
};

bool isBuiltin = false;
for (const auto& n : builtinThemes)
{
    if (name == n) {
        isBuiltin = true;
        break;
    }
}
if (isBuiltin)
{
    continue;
}
```

It's more verbose, but only for us. Look how much less it is for the CPU! https://godbolt.org/z/Gb517xzje
I don't want to block you over that, since the current approach works too, but I think this would be much better.

It's unfortunate that C++ doesn't have a `continue label;` syntax to jump to an outer loop, because:
```cpp
for (const auto& n : builtinThemes)
{
    continue outer;
}
```

...much easier to read. You can technically use `goto` for that, but I don't want to bother you with the resulting warnings (it would be safe to do this).

Code after:

    // "profiles" will always be serialized as an object
    Json::Value profiles{ Json::ValueType::objectValue };
    profiles[JsonKey(DefaultSettingsKey)] = _baseLayerProfile ? _baseLayerProfile->ToJson() : Json::ValueType::objectValue;
    Json::Value profilesList{ Json::ValueType::arrayValue };
    for (const auto& entry : _allProfiles)
    {
        if (!entry.Deleted())
        {
            const auto prof{ winrt::get_self<Profile>(entry) };
            profilesList.append(prof->ToJson());
        }
    }
    profiles[JsonKey(ProfilesListKey)] = profilesList;
    json[JsonKey(ProfilesKey)] = profiles;

    // TODO GH#8100:
    // "schemes" will be an accumulation of _all_ the color schemes
    // including all of the ones from defaults.json
    Json::Value schemes{ Json::ValueType::arrayValue };
    for (const auto& entry : _globals->ColorSchemes())
    {
        const auto scheme{ winrt::get_self<ColorScheme>(entry.Value()) };
        schemes.append(scheme->ToJson());
    }
    json[JsonKey(SchemesKey)] = schemes;

    Json::Value themes{ Json::ValueType::arrayValue };
    for (const auto& entry : _globals->Themes())
    {
        // Ignore the built in themes, when serializing the themes back out. We
        // don't want to re-include them in the user settings file.
        const auto theme{ winrt::get_self<Theme>(entry.Value()) };
        const auto& name{ theme->Name() };
        if (std::ranges::find(builtinThemes, name) != builtinThemes.end())
        {
            continue;
        }
        themes.append(theme->ToJson());
    }
    json[JsonKey(ThemesKey)] = themes;

    return json;
}

// Method Description:
// - Resolves the "defaultProfile", which can be a profile name, to a GUID
//   and stores it back to the globals.
void CascadiaSettings::_resolveDefaultProfile() const
{
    if (const auto unparsedDefaultProfile = _globals->UnparsedDefaultProfile(); !unparsedDefaultProfile.empty())