From c77b851cc2c554f6fb723f3a38bbf29125ff03a4 Mon Sep 17 00:00:00 2001 From: scheffle Date: Sun, 25 Feb 2024 16:51:12 +0100 Subject: [PATCH] do not calculate the line width when the line does not change --- vstgui/lib/ctexteditor.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/vstgui/lib/ctexteditor.cpp b/vstgui/lib/ctexteditor.cpp index 0c6dbc179..cdb299dbc 100644 --- a/vstgui/lib/ctexteditor.cpp +++ b/vstgui/lib/ctexteditor.cpp @@ -1236,8 +1236,12 @@ void TextEditorView::invalidate (Dirty what) const //------------------------------------------------------------------------ CCoord TextEditorView::updateLineText (Lines::iterator& line) const { - line->text = convert (md.model.text.data () + line->range.start, line->range.length); - line->width = md.fontPainer->getStringWidth (nullptr, line->text.getPlatformString ()); + auto newText = convert (md.model.text.data () + line->range.start, line->range.length); + if (newText != line->text) + { + line->text = std::move (newText); + line->width = md.fontPainer->getStringWidth (nullptr, line->text.getPlatformString ()); + } return line->width; }