Throttle cursor redrawing in outputStream.cpp (#10394)
Try to throttle the cursor redrawing in the conhost world. The motivation of this is the high CPU usage of `TriggerRedrawCursor` (#10393). This can be seen as the conhost version of #2960. This saves 5%~8% of the CPU time. Supports #10462.
This commit is contained in:
parent
51e1ae3e8a
commit
4fc283f8b6
|
@ -76,8 +76,15 @@ void WriteBuffer::_DefaultStringCase(const std::wstring_view string)
|
|||
{
|
||||
size_t dwNumBytes = string.size() * sizeof(wchar_t);
|
||||
|
||||
_io.GetActiveOutputBuffer().GetTextBuffer().GetCursor().SetIsOn(true);
|
||||
Cursor& cursor = _io.GetActiveOutputBuffer().GetTextBuffer().GetCursor();
|
||||
if (!cursor.IsOn())
|
||||
{
|
||||
cursor.SetIsOn(true);
|
||||
}
|
||||
|
||||
// Defer the cursor drawing while we are iterating the string, for a better performance.
|
||||
// We can not waste time displaying a cursor event when we know more text is coming right behind it.
|
||||
cursor.StartDeferDrawing();
|
||||
_ntstatus = WriteCharsLegacy(_io.GetActiveOutputBuffer(),
|
||||
string.data(),
|
||||
string.data(),
|
||||
|
@ -87,6 +94,7 @@ void WriteBuffer::_DefaultStringCase(const std::wstring_view string)
|
|||
_io.GetActiveOutputBuffer().GetTextBuffer().GetCursor().GetPosition().X,
|
||||
WC_LIMIT_BACKSPACE | WC_DELAY_EOL_WRAP,
|
||||
nullptr);
|
||||
cursor.EndDeferDrawing();
|
||||
}
|
||||
|
||||
ConhostInternalGetSet::ConhostInternalGetSet(_In_ IIoProvider& io) :
|
||||
|
|
Loading…
Reference in a new issue