Repository: microsoft/terminal
File: src/cascadia/TerminalSettingsEditor/Appearances.cpp (C++)

Code before:
{
    bool Font::HasPowerlineCharacters()
    {
        if (!_hasPowerlineCharacters.has_value())
        {
            try
            {
                winrt::com_ptr<IDWriteFont> font;
                THROW_IF_FAILED(_family->GetFont(0, font.put()));
                BOOL exists{};
                // We're actually checking for the "Extended" PowerLine glyph set.
                // They're more fun.
                THROW_IF_FAILED(font->HasCharacter(0xE0B6, &exists));
                _hasPowerlineCharacters = (exists == TRUE);
            }
            catch (...)
            {
                _hasPowerlineCharacters = false;
            }
        }
        return _hasPowerlineCharacters.value_or(false);
    }

    Windows::Foundation::Collections::IMap<winrt::hstring, winrt::hstring> Font::FontAxesTagsAndNames()
    {
        auto fontAxesTagsAndNames = winrt::single_threaded_map<winrt::hstring, winrt::hstring>();

        wil::com_ptr<IDWriteFont> font;
        THROW_IF_FAILED(_family->GetFont(0, font.put()));
        wil::com_ptr<IDWriteFontFace> fontFace;
        THROW_IF_FAILED(font->CreateFontFace(fontFace.put()));
        wil::com_ptr<IDWriteFontFace5> fontFace5;
        if (fontFace5 = fontFace.try_query<IDWriteFontFace5>())
        {
            wil::com_ptr<IDWriteFontResource> fontResource;
            THROW_IF_FAILED(fontFace5->GetFontResource(fontResource.put()));

            std::vector<DWRITE_FONT_AXIS_VALUE> axesVector;
            const auto axesCount = fontFace5->GetFontAxisValueCount();
            if (axesCount > 0)
            {
                uint32_t localeIndex;
                BOOL localeExists;
                wchar_t localeName[LOCALE_NAME_MAX_LENGTH];
                const auto localeToTry = GetUserDefaultLocaleName(localeName, LOCALE_NAME_MAX_LENGTH) ? localeName : L"en-US";

                axesVector.resize(axesCount);
                fontFace5->GetFontAxisValues(axesVector.data(), axesCount);
                for (uint32_t i = 0; i < axesCount; ++i)
                {
                    const auto tagString = _axisTagToString(axesVector[i].axisTag);

Review comment (performance):
this could at least start by building a `std::map` internally, then `std::move` the map into a `single_threaded_map` as the return value. That way you at least get performance while constructing the map. 

Code after:
{
    bool Font::HasPowerlineCharacters()
    {
        if (!_hasPowerlineCharacters.has_value())
        {
            try
            {
                winrt::com_ptr<IDWriteFont> font;
                THROW_IF_FAILED(_family->GetFont(0, font.put()));
                BOOL exists{};
                // We're actually checking for the "Extended" PowerLine glyph set.
                // They're more fun.
                THROW_IF_FAILED(font->HasCharacter(0xE0B6, &exists));
                _hasPowerlineCharacters = (exists == TRUE);
            }
            catch (...)
            {
                _hasPowerlineCharacters = false;
            }
        }
        return _hasPowerlineCharacters.value_or(false);
    }

    Windows::Foundation::Collections::IMap<winrt::hstring, winrt::hstring> Font::FontAxesTagsAndNames()
    {
        if (!_fontAxesTagsAndNames)
        {
            wil::com_ptr<IDWriteFont> font;
            THROW_IF_FAILED(_family->GetFont(0, font.put()));
            wil::com_ptr<IDWriteFontFace> fontFace;
            THROW_IF_FAILED(font->CreateFontFace(fontFace.put()));
            wil::com_ptr<IDWriteFontFace5> fontFace5;
            if (fontFace5 = fontFace.try_query<IDWriteFontFace5>())
            {
                wil::com_ptr<IDWriteFontResource> fontResource;
                THROW_IF_FAILED(fontFace5->GetFontResource(fontResource.put()));

                const auto axesCount = fontFace5->GetFontAxisValueCount();
                if (axesCount > 0)
                {
                    std::vector<DWRITE_FONT_AXIS_VALUE> axesVector(axesCount);
                    fontFace5->GetFontAxisValues(axesVector.data(), axesCount);

                    uint32_t localeIndex;
                    BOOL localeExists;
                    wchar_t localeName[LOCALE_NAME_MAX_LENGTH];
                    const auto localeToTry = GetUserDefaultLocaleName(localeName, LOCALE_NAME_MAX_LENGTH) ? localeName : L"en-US";

                    std::unordered_map<winrt::hstring, winrt::hstring> fontAxesTagsAndNames;
                    for (uint32_t i = 0; i < axesCount; ++i)
                    {