Repository: microsoft/terminal
File: src/cascadia/TerminalApp/App.cpp (C++)

Code before:

            auto tabViewItem = tab->GetTabViewItem();
            tabViewItem.Dispatcher().RunAsync(CoreDispatcherPriority::Normal, [this, lastFocusedProfile, tabViewItem]() {
                // _GetIconFromProfile has to run on the main thread
                const auto* const matchingProfile = _settings->FindProfile(lastFocusedProfile);
                if (matchingProfile)
                {
                    tabViewItem.Icon(App::_GetIconFromProfile(*matchingProfile));
                }
            });
        }
    }

    // Method Description:
    // - Get the title of the currently focused terminal control, and set it's
    //   tab's text to that text. If this tab is the focused tab, then also
    //   bubble this title to any listeners of our TitleChanged event.
    // Arguments:
    // - tab: the Tab to update the title for.
    void App::_UpdateTitle(std::shared_ptr<Tab> tab)
    {
        auto newTabTitle = tab->GetFocusedTitle();
        const auto lastFocusedProfile = tab->GetFocusedProfile().value();
        const auto* const matchingProfile = _settings->FindProfile(lastFocusedProfile);

        auto tabTitle = matchingProfile->GetTabTitle();

        // Checks if tab title has been set in the profile settings and
        // updates accordingly.

        const auto newActualTitle = tabTitle.empty() ? newTabTitle : tabTitle;

        tab->SetTabText(winrt::to_hstring(newActualTitle.data()));
        if (_settings->GlobalSettings().GetShowTitleInTitlebar() &&
            tab->IsFocused())
        {
            _titleChangeHandlers(newActualTitle);
        }
    }

    // Method Description:
    // - Update the current theme of the application. This will manually update
    //   all of the elements in our UI to match the given theme.
    // Arguments:
    // - newTheme: The ElementTheme to apply to our elements.
    void App::_ApplyTheme(const Windows::UI::Xaml::ElementTheme& newTheme)
    {
        _root.RequestedTheme(newTheme);
        _tabRow.RequestedTheme(newTheme);
    }


Review comment (suggestion):
```suggestion
        const auto tabTitle = matchingProfile->GetTabTitle();
```

This can be const with the way you wrote it now.

Code after:

            auto tabViewItem = tab->GetTabViewItem();
            tabViewItem.Dispatcher().RunAsync(CoreDispatcherPriority::Normal, [this, lastFocusedProfile, tabViewItem]() {
                // _GetIconFromProfile has to run on the main thread
                const auto* const matchingProfile = _settings->FindProfile(lastFocusedProfile);
                if (matchingProfile)
                {
                    tabViewItem.Icon(App::_GetIconFromProfile(*matchingProfile));
                }
            });
        }
    }

    // Method Description:
    // - Get the title of the currently focused terminal control, and set it's
    //   tab's text to that text. If this tab is the focused tab, then also
    //   bubble this title to any listeners of our TitleChanged event.
    // Arguments:
    // - tab: the Tab to update the title for.
    void App::_UpdateTitle(std::shared_ptr<Tab> tab)
    {
        auto newTabTitle = tab->GetFocusedTitle();
        const auto lastFocusedProfile = tab->GetFocusedProfile().value();
        const auto* const matchingProfile = _settings->FindProfile(lastFocusedProfile);

        const auto tabTitle = matchingProfile->GetTabTitle();

        // Checks if tab title has been set in the profile settings and
        // updates accordingly.

        const auto newActualTitle = tabTitle.empty() ? newTabTitle : tabTitle;

        tab->SetTabText(winrt::to_hstring(newActualTitle.data()));
        if (_settings->GlobalSettings().GetShowTitleInTitlebar() &&
            tab->IsFocused())
        {
            _titleChangeHandlers(newActualTitle);
        }
    }

    // Method Description:
    // - Update the current theme of the application. This will manually update
    //   all of the elements in our UI to match the given theme.
    // Arguments:
    // - newTheme: The ElementTheme to apply to our elements.
    void App::_ApplyTheme(const Windows::UI::Xaml::ElementTheme& newTheme)
    {
        _root.RequestedTheme(newTheme);
        _tabRow.RequestedTheme(newTheme);
    }