Skip to content

Commit

Permalink
Call updateHighlighting at most once when definitionChanged
Browse files Browse the repository at this point in the history
Instead of using a signal connection here, call the function
directly. This is slightly more efficient, but - more importantly -
ensures we don't reconnect this signal multiple times, once every
time we call HighlightedText::setText.
  • Loading branch information
milianw committed Jan 24, 2024
1 parent 7f51ba5 commit e16fb89
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/models/highlightedtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,6 @@ void HighlightedText::setText(const QStringList& text)
return HighlightedLine {m_highlighter.get(), text};
});

connect(this, &HighlightedText::definitionChanged, this, &HighlightedText::updateHighlighting);

m_cleanedLines.reserve(text.size());
std::transform(text.cbegin(), text.cend(), std::back_inserter(m_cleanedLines), Util::removeAnsi);
}
Expand All @@ -275,6 +273,7 @@ void HighlightedText::setDefinition(const KSyntaxHighlighting::Definition& defin
m_highlighter->setHighlightingDefinition(definition);
#if KFSyntaxHighlighting_FOUND
emit definitionChanged(definition.name());
updateHighlighting();
#endif
}

Expand Down

0 comments on commit e16fb89

Please sign in to comment.