Repository: microsoft/terminal
File: src/renderer/atlas/AtlasEngine.cpp (C++)

Code before:
                _api.invalidatedRows.y = nothingInvalid ? _api.scrollOffset : std::max<u16>(_api.invalidatedRows.y, _api.scrollOffset);
            }

            memmove(dst, src, count * sizeof(Cell));
        }
    }

    if constexpr (debugGlyphGenerationPerformance)
    {
        _api.dirtyRect = til::rect{ 0, 0, _api.cellCount.x, _api.cellCount.y };
    }
    else
    {
        _api.dirtyRect = til::rect{ 0, _api.invalidatedRows.x, _api.cellCount.x, _api.invalidatedRows.y };
    }

    // This is an important block of code for our TileHashMap.
    // We only process glyphs within the dirtyRect, but glyphs outside of the
    // dirtyRect are still in use and shouldn't be discarded. This is critical
    // if someone uses a tool like tmux to split the terminal horizontally.
    // If they then print a lot of Unicode text on just one side, we have to
    // ensure that the (for example) plain ASCII glyphs on the other half of the
    // viewport are still retained. This bit of code "refreshes" those glyphs and
    // brings them to the front of the LRU queue to prevent them from being reused.
    {
        std::array<til::point, 2> ranges{ {
            { 0, _api.dirtyRect.top },
            { _api.dirtyRect.bottom, _api.cellCount.y },
        } };
        const auto stride = static_cast<size_t>(_r.cellCount.x);
        for (const auto& p : ranges)
        {
            const auto from = p.x;
            const auto to = p.y;
            for (auto y = from; y < to; ++y)
            {
                auto it = _r.cellGlyphMapping.data() + stride * y;
                const auto end = it + stride;
                for (; it != end; ++it)
                {
                    _r.glyphs.makeNewest(*it);
                }
            }
        }
    }

    return S_OK;
}
catch (const wil::ResultException& exception)
{
    return _handleException(exception);

Review comment (suggestion):
```suggestion
        const std::array<til::point, 2> ranges{ {
```

Code after:
                _api.invalidatedRows.y = nothingInvalid ? _api.scrollOffset : std::max<u16>(_api.invalidatedRows.y, _api.scrollOffset);
            }

            memmove(dst, src, count * sizeof(Cell));
        }
    }

    if constexpr (debugGlyphGenerationPerformance)
    {
        _api.dirtyRect = til::rect{ 0, 0, _api.cellCount.x, _api.cellCount.y };
    }
    else
    {
        _api.dirtyRect = til::rect{ 0, _api.invalidatedRows.x, _api.cellCount.x, _api.invalidatedRows.y };
    }

    // This is an important block of code for our TileHashMap.
    // We only process glyphs within the dirtyRect, but glyphs outside of the
    // dirtyRect are still in use and shouldn't be discarded. This is critical
    // if someone uses a tool like tmux to split the terminal horizontally.
    // If they then print a lot of Unicode text on just one side, we have to
    // ensure that the (for example) plain ASCII glyphs on the other half of the
    // viewport are still retained. This bit of code "refreshes" those glyphs and
    // brings them to the front of the LRU queue to prevent them from being reused.
    {
        const std::array<til::point, 2> ranges{ {
            { 0, _api.dirtyRect.top },
            { _api.dirtyRect.bottom, _api.cellCount.y },
        } };
        const auto stride = static_cast<size_t>(_r.cellCount.x);

        for (const auto& p : ranges)
        {
            // We (ab)use the .x/.y members of the til::point as the
            // respective [from,to) range of rows we need to makeNewest().
            const auto from = p.x;
            const auto to = p.y;

            for (auto y = from; y < to; ++y)
            {
                auto it = _r.cellGlyphMapping.data() + stride * y;
                const auto end = it + stride;
                for (; it != end; ++it)
                {
                    _r.glyphs.makeNewest(*it);
                }
            }
        }
    }

    return S_OK;