-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache VT buffer line string to avoid (de)alloc on every paint #6840
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -204,6 +204,9 @@ namespace Microsoft::Console::Render | |
|
||
bool _WillWriteSingleChar() const; | ||
|
||
// buffer space for these two functions to build their lines | ||
// so they don't have to alloc/free in a tight loop | ||
std::wstring _bufferLine; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we want to til::manage? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We discussed this a bit in Teams. This should max out at approximately ( I could come up with some sort of time-based decay of the size of the allocation (if someone was doing big draws and has now been doing little draws for a while, it could release it back.... but I don't really have a justification to do all that to pay back ~240 bytes of memory.) Also, we only have We decided together that this is a big MEH. |
||
[[nodiscard]] HRESULT _PaintUtf8BufferLine(std::basic_string_view<Cluster> const clusters, | ||
const COORD coord, | ||
const bool lineWrapped) noexcept; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it not possible to pass the wstring directly as a view? bah.
were we literally making a whole copy of the wstring to a wstring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why the copy was there. It's probably because the
_WriteTerminalUtf8
function converted to usingstd::wstring_view
fromstd::wstring
at a point in time after this paint function was last updated and this became a mechanical replace.As for why we don't pass
_bufferLine
directly, thecchActual
may be less than the length of the full buffer depending on trimming calculations performed above.