From 8ac99680962fc4c01dd561716f0b927d386bc7e8 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Mon, 19 Dec 2022 22:20:58 +0100 Subject: [PATCH] Qt: optimize log viewer file loading --- rpcs3/rpcs3qt/log_viewer.cpp | 13 ++++--------- rpcs3/rpcs3qt/syntax_highlighter.cpp | 4 ++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/rpcs3/rpcs3qt/log_viewer.cpp b/rpcs3/rpcs3qt/log_viewer.cpp index fa4021da65..8cf0cded96 100644 --- a/rpcs3/rpcs3qt/log_viewer.cpp +++ b/rpcs3/rpcs3qt/log_viewer.cpp @@ -224,9 +224,8 @@ void log_viewer::show_log() m_gui_settings->SetValue(gui::fd_log_viewer, m_path_last); QTextStream stream(&file); - QString text = stream.readAll(); - text.replace('\0', '0'); - set_text_and_keep_position(text); + m_full_log = stream.readAll(); + m_full_log.replace('\0', '0'); file.close(); } else @@ -252,12 +251,8 @@ void log_viewer::filter_log() { if (m_full_log.isEmpty()) { - m_full_log = m_log_text->toPlainText(); - - if (m_full_log.isEmpty()) - { - return; - } + set_text_and_keep_position(m_full_log); + return; } m_log_text->setPlainText(tr("Filtering...")); diff --git a/rpcs3/rpcs3qt/syntax_highlighter.cpp b/rpcs3/rpcs3qt/syntax_highlighter.cpp index 38ba412c13..da33f40c60 100644 --- a/rpcs3/rpcs3qt/syntax_highlighter.cpp +++ b/rpcs3/rpcs3qt/syntax_highlighter.cpp @@ -15,7 +15,7 @@ void Highlighter::addRule(const QString &pattern, const QBrush &brush) void Highlighter::highlightBlock(const QString &text) { - for (const HighlightingRule &rule : highlightingRules) + for (const HighlightingRule& rule : highlightingRules) { QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text); while (matchIterator.hasNext()) @@ -168,7 +168,7 @@ GlslHighlighter::GlslHighlighter(QTextDocument *parent) : Highlighter(parent) << "r16_snorm" << "r32ui" << "r8_snorm" << "r16ui"; - for (const QString &pattern : keywordPatterns) + for (const QString& pattern : keywordPatterns) addRule("\\b" + pattern + "\\b", Qt::darkBlue); // normal words like: soka, nani, or gomen addRule("\\bGL_(?:[A-Z]|_)+\\b", Qt::darkMagenta); // constants like: GL_OMAE_WA_MOU_SHINDEIRU