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

Code before:
        {
            // Override commandline, starting directory if they exist in newTerminalArgs
            if (!newTerminalArgs.Commandline().empty())
            {
                settings.Commandline(newTerminalArgs.Commandline());
            }
            if (!newTerminalArgs.StartingDirectory().empty())
            {
                settings.StartingDirectory(newTerminalArgs.StartingDirectory());
            }
            if (!newTerminalArgs.TabTitle().empty())
            {
                settings.StartingTitle(newTerminalArgs.TabTitle());
            }
            if (newTerminalArgs.TabColor())
            {
                settings.StartingTabColor(static_cast<uint32_t>(til::color(newTerminalArgs.TabColor().Value())));
            }
            if (newTerminalArgs.SuppressApplicationTitle())
            {
                settings.SuppressApplicationTitle(newTerminalArgs.SuppressApplicationTitle().Value());
            }
            if (!newTerminalArgs.ColorScheme().empty())
            {
                const auto schemes = appSettings.GlobalSettings().ColorSchemes();
                if (const auto scheme = schemes.TryLookup(newTerminalArgs.ColorScheme()))
                {
                    settings.ApplyColorScheme(scheme);
                }
            }
        }

        return settings;
    }

    // Method Description:
    // - Creates a TerminalSettings object that inherits from a parent TerminalSettings
    // Arguments::
    // - parent: the TerminalSettings object that the newly created TerminalSettings will inherit from
    // Return Value:
    // - a newly created child of the given parent object
    Model::TerminalSettings TerminalSettings::CreateWithParent(const Model::TerminalSettings& parent)
    {
        THROW_HR_IF_NULL(E_INVALIDARG, parent);

        auto parentImpl{ get_self<TerminalSettings>(parent) };
        return *parentImpl->CreateChild();
    }

    // Method Description:
    // - Sets our parent to the provided TerminalSettings

Review comment (performance):
```suggestion
                if (const auto& scheme = schemes.TryLookup(newTerminalArgs.ColorScheme()))
```

Who knows, the compiler may optimize this one. Probably won't optimize the above one.

Code after:
        {
            // Override commandline, starting directory if they exist in newTerminalArgs
            if (!newTerminalArgs.Commandline().empty())
            {
                settings.Commandline(newTerminalArgs.Commandline());
            }
            if (!newTerminalArgs.StartingDirectory().empty())
            {
                settings.StartingDirectory(newTerminalArgs.StartingDirectory());
            }
            if (!newTerminalArgs.TabTitle().empty())
            {
                settings.StartingTitle(newTerminalArgs.TabTitle());
            }
            if (newTerminalArgs.TabColor())
            {
                settings.StartingTabColor(static_cast<uint32_t>(til::color(newTerminalArgs.TabColor().Value())));
            }
            if (newTerminalArgs.SuppressApplicationTitle())
            {
                settings.SuppressApplicationTitle(newTerminalArgs.SuppressApplicationTitle().Value());
            }
            if (!newTerminalArgs.ColorScheme().empty())
            {
                const auto schemes = appSettings.GlobalSettings().ColorSchemes();
                if (const auto& scheme = schemes.TryLookup(newTerminalArgs.ColorScheme()))
                {
                    settings.ApplyColorScheme(scheme);
                }
            }
        }

        return settings;
    }

    // Method Description:
    // - Creates a TerminalSettings object that inherits from a parent TerminalSettings
    // Arguments::
    // - parent: the TerminalSettings object that the newly created TerminalSettings will inherit from
    // Return Value:
    // - a newly created child of the given parent object
    Model::TerminalSettings TerminalSettings::CreateWithParent(const Model::TerminalSettings& parent)
    {
        THROW_HR_IF_NULL(E_INVALIDARG, parent);

        auto parentImpl{ get_self<TerminalSettings>(parent) };
        return *parentImpl->CreateChild();
    }

    // Method Description:
    // - Sets our parent to the provided TerminalSettings