Repository: microsoft/terminal
File: src/renderer/vt/paint.cpp (C++)

Code before:
    }
    _circled = false;

    // If _stopUsingLineRenditions is still true at the end of the frame, that
    // means we've refreshed the entire viewport with every line being single
    // width, so we can safely stop using them from now on.
    if (_stopUsingLineRenditions)
    {
        _usingLineRenditions = false;
    }

    // If we deferred a cursor movement during the frame, make sure we put the
    //      cursor in the right place before we end the frame.
    if (_deferredCursorPos != INVALID_COORDS)
    {
        RETURN_IF_FAILED(_MoveCursor(_deferredCursorPos));
    }

    RETURN_IF_FAILED(_Flush());

    return S_OK;
}

// Routine Description:
// - Used to perform longer running presentation steps outside the lock so the
//      other threads can continue.
// - Not currently used by VtEngine.
// Arguments:
// - <none>
// Return Value:
// - S_FALSE since we do nothing.
[[nodiscard]] HRESULT VtEngine::Present() noexcept
{
    return S_FALSE;
}

[[nodiscard]] HRESULT VtEngine::ResetLineTransform() noexcept
{
    return S_FALSE;
}

[[nodiscard]] HRESULT VtEngine::PrepareLineTransform(const LineRendition lineRendition,
                                                     const til::CoordType targetRow,
                                                     const til::CoordType /*viewportLeft*/) noexcept
{
    // We don't want to waste bandwidth writing out line rendition attributes
    // until we know they're in use. But once they are in use, we have to keep
    // applying them on every line until we know they definitely aren't being
    // used anymore (we check that at the end of any fullscreen paint).
    if (lineRendition != LineRendition::SingleWidth)
    {

Review comment (suggestion):
FYI I don't think the `[[unlikely]]` is worth it here. Its implementation is super dumb in MSVC and causes any and all affected unlikely code to be moved to the end of the function, even if it's literally just a single `mov [rcx+1234], 0` instruction like here. I think it's still useful, but it seems like its usage is mostly restricted to a rather "nuanced" application, especially after observing the disassembly output.

Code after:
    }
    _circled = false;

    // If _stopUsingLineRenditions is still true at the end of the frame, that
    // means we've refreshed the entire viewport with every line being single
    // width, so we can safely stop using them from now on.
    if (_stopUsingLineRenditions)
    {
        _usingLineRenditions = false;
    }

    // If we deferred a cursor movement during the frame, make sure we put the
    //      cursor in the right place before we end the frame.
    if (_deferredCursorPos != INVALID_COORDS)
    {
        RETURN_IF_FAILED(_MoveCursor(_deferredCursorPos));
    }

    // If this frame was triggered because we encountered a VT sequence which
    // required the buffered state to get printed, we don't want to flush this
    // frame to the pipe. That might result in us rendering half the output of a
    // particular frame (as emitted by the client).
    //
    // Instead, we'll leave this frame in _buffer, and just keep appending to
    // it as needed.
    if (_noFlushOnEnd) [[unlikely]]
    {
        _noFlushOnEnd = false;
    }
    else
    {
        RETURN_IF_FAILED(_Flush());
    }

    return S_OK;
}

// Routine Description:
// - Used to perform longer running presentation steps outside the lock so the
//      other threads can continue.
// - Not currently used by VtEngine.
// Arguments:
// - <none>
// Return Value:
// - S_FALSE since we do nothing.
[[nodiscard]] HRESULT VtEngine::Present() noexcept
{
    return S_FALSE;
}

[[nodiscard]] HRESULT VtEngine::ResetLineTransform() noexcept