From 0e421ae415ccc2722bb9bb80c1a7208b9558233c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Pereira?= Date: Wed, 21 Feb 2018 18:29:22 +0000 Subject: [PATCH] Don't create temporary substrings Avoid temporary string allocations. They are only used to convert to something else. QString::xxxRef() returns a QStringRef. QStringRef avoids the memory allocation and reference counting overhead of a standard QString by simply referencing a part of the original string. --- src/app/application.cpp | 4 ++-- src/base/rss/rss_autodownloadrule.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/application.cpp b/src/app/application.cpp index ebc32f909..05b207a2c 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -401,7 +401,7 @@ void Application::processParams(const QStringList ¶ms) } if (param.startsWith(QLatin1String("@addPaused="))) { - torrentParams.addPaused = param.mid(11).toInt() ? TriStateBool::True : TriStateBool::False; + torrentParams.addPaused = param.midRef(11).toInt() ? TriStateBool::True : TriStateBool::False; continue; } @@ -426,7 +426,7 @@ void Application::processParams(const QStringList ¶ms) } if (param.startsWith(QLatin1String("@skipDialog="))) { - skipTorrentDialog = param.mid(12).toInt() ? TriStateBool::True : TriStateBool::False; + skipTorrentDialog = param.midRef(12).toInt() ? TriStateBool::True : TriStateBool::False; continue; } diff --git a/src/base/rss/rss_autodownloadrule.cpp b/src/base/rss/rss_autodownloadrule.cpp index dda3c2d07..d34bf8366 100644 --- a/src/base/rss/rss_autodownloadrule.cpp +++ b/src/base/rss/rss_autodownloadrule.cpp @@ -302,7 +302,7 @@ bool AutoDownloadRule::matches(const QString &articleTitle) const QRegularExpression reg(cachedRegex(partialPattern1)); if (ep.endsWith('-')) { // Infinite range - int epOurs = ep.left(ep.size() - 1).toInt(); + int epOurs = ep.leftRef(ep.size() - 1).toInt(); // Extract partial match from article and compare as digits matcher = reg.match(articleTitle);