From 8c9b6e2f2dd70ef512f03359091def425b8e55b6 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 5 May 2023 02:50:19 +0800 Subject: [PATCH] Use reference whenever possible --- src/base/bittorrent/customstorage.cpp | 2 +- src/base/bittorrent/sessionimpl.cpp | 2 +- src/base/bittorrent/torrentimpl.cpp | 2 +- src/base/net/smtp.cpp | 2 +- src/base/rss/rss_autodownloader.cpp | 4 ++-- src/base/rss/rss_parser.cpp | 2 +- src/base/rss/rss_parser.h | 2 +- src/base/search/searchpluginmanager.cpp | 2 +- src/base/search/searchpluginmanager.h | 2 +- src/gui/transferlistfilters/statusfilterwidget.cpp | 2 +- src/gui/transferlistfilters/statusfilterwidget.h | 2 +- src/webui/api/appcontroller.cpp | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/base/bittorrent/customstorage.cpp b/src/base/bittorrent/customstorage.cpp index 74f4f9e21..2d25e45a3 100644 --- a/src/base/bittorrent/customstorage.cpp +++ b/src/base/bittorrent/customstorage.cpp @@ -171,7 +171,7 @@ void CustomDiskIOThread::async_set_file_priority(lt::storage_index_t storage, lt , std::function)> handler) { m_nativeDiskIO->async_set_file_priority(storage, priorities - , [=, handler = std::move(handler)](const lt::storage_error &error, lt::aux::vector priorities) + , [=, handler = std::move(handler)](const lt::storage_error &error, const lt::aux::vector &priorities) { m_storageData[storage].filePriorities = priorities; handler(error, priorities); diff --git a/src/base/bittorrent/sessionimpl.cpp b/src/base/bittorrent/sessionimpl.cpp index 40557e227..e95fca2a3 100644 --- a/src/base/bittorrent/sessionimpl.cpp +++ b/src/base/bittorrent/sessionimpl.cpp @@ -4986,7 +4986,7 @@ void SessionImpl::upgradeCategories() const auto legacyCategories = SettingValue(u"BitTorrent/Session/Categories"_qs).get(); for (auto it = legacyCategories.cbegin(); it != legacyCategories.cend(); ++it) { - const QString categoryName = it.key(); + const QString &categoryName = it.key(); CategoryOptions categoryOptions; categoryOptions.savePath = Path(it.value().toString()); m_categories[categoryName] = categoryOptions; diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index fc51f1caf..b064fd5e7 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -1632,7 +1632,7 @@ void TorrentImpl::endReceivedMetadataHandling(const Path &savePath, const PathLi { const auto nativeIndex = nativeIndexes.at(i); - const Path actualFilePath = fileNames.at(i); + const Path &actualFilePath = fileNames.at(i); p.renamed_files[nativeIndex] = actualFilePath.toString().toStdString(); const Path filePath = actualFilePath.removedExtension(QB_EXT); diff --git a/src/base/net/smtp.cpp b/src/base/net/smtp.cpp index d34ef9edc..f0cffb594 100644 --- a/src/base/net/smtp.cpp +++ b/src/base/net/smtp.cpp @@ -162,7 +162,7 @@ void Smtp::sendMail(const QString &from, const QString &to, const QString &subje // Connect to SMTP server const QStringList serverEndpoint = pref->getMailNotificationSMTP().split(u':'); - const QString serverAddress = serverEndpoint[0]; + const QString &serverAddress = serverEndpoint[0]; const std::optional serverPort = Utils::String::parseInt(serverEndpoint.value(1)); #ifndef QT_NO_OPENSSL diff --git a/src/base/rss/rss_autodownloader.cpp b/src/base/rss/rss_autodownloader.cpp index 1c74e169c..6aab0504a 100644 --- a/src/base/rss/rss_autodownloader.cpp +++ b/src/base/rss/rss_autodownloader.cpp @@ -382,13 +382,13 @@ void AutoDownloader::handleFeedURLChanged(Feed *feed, const QString &oldURL) } } - for (QSharedPointer job : asConst(m_processingQueue)) + for (const QSharedPointer &job : asConst(m_processingQueue)) { if (job->feedURL == oldURL) job->feedURL = feed->url(); } - for (QSharedPointer job : asConst(m_waitingJobs)) + for (const QSharedPointer &job : asConst(m_waitingJobs)) { if (job->feedURL == oldURL) job->feedURL = feed->url(); diff --git a/src/base/rss/rss_parser.cpp b/src/base/rss/rss_parser.cpp index a312ba314..e07e7811d 100644 --- a/src/base/rss/rss_parser.cpp +++ b/src/base/rss/rss_parser.cpp @@ -541,7 +541,7 @@ namespace const int PARSINGRESULT_TYPEID = qRegisterMetaType(); -RSS::Private::Parser::Parser(const QString lastBuildDate) +RSS::Private::Parser::Parser(const QString &lastBuildDate) { m_result.lastBuildDate = lastBuildDate; } diff --git a/src/base/rss/rss_parser.h b/src/base/rss/rss_parser.h index d5fc4f938..7abfeeb2e 100644 --- a/src/base/rss/rss_parser.h +++ b/src/base/rss/rss_parser.h @@ -53,7 +53,7 @@ namespace RSS::Private Q_DISABLE_COPY_MOVE(Parser) public: - explicit Parser(QString lastBuildDate); + explicit Parser(const QString &lastBuildDate); void parse(const QByteArray &feedData); signals: diff --git a/src/base/search/searchpluginmanager.cpp b/src/base/search/searchpluginmanager.cpp index 097c34045..b697ef05b 100644 --- a/src/base/search/searchpluginmanager.cpp +++ b/src/base/search/searchpluginmanager.cpp @@ -609,7 +609,7 @@ void SearchPluginManager::parseVersionInfo(const QByteArray &info) } } -bool SearchPluginManager::isUpdateNeeded(const QString &pluginName, const PluginVersion newVersion) const +bool SearchPluginManager::isUpdateNeeded(const QString &pluginName, const PluginVersion &newVersion) const { const PluginInfo *plugin = pluginInfo(pluginName); if (!plugin) return true; diff --git a/src/base/search/searchpluginmanager.h b/src/base/search/searchpluginmanager.h index e7d1daebe..0425f9439 100644 --- a/src/base/search/searchpluginmanager.h +++ b/src/base/search/searchpluginmanager.h @@ -109,7 +109,7 @@ private: void updateNova(); void parseVersionInfo(const QByteArray &info); void installPlugin_impl(const QString &name, const Path &path); - bool isUpdateNeeded(const QString &pluginName, PluginVersion newVersion) const; + bool isUpdateNeeded(const QString &pluginName, const PluginVersion &newVersion) const; void versionInfoDownloadFinished(const Net::DownloadResult &result); void pluginDownloadFinished(const Net::DownloadResult &result); diff --git a/src/gui/transferlistfilters/statusfilterwidget.cpp b/src/gui/transferlistfilters/statusfilterwidget.cpp index e0caf03f7..9fcb9af3d 100644 --- a/src/gui/transferlistfilters/statusfilterwidget.cpp +++ b/src/gui/transferlistfilters/statusfilterwidget.cpp @@ -199,7 +199,7 @@ void StatusFilterWidget::hideZeroItems() setCurrentRow(TorrentFilter::All, QItemSelectionModel::SelectCurrent); } -void StatusFilterWidget::update(const QVector torrents) +void StatusFilterWidget::update(const QVector &torrents) { for (const BitTorrent::Torrent *torrent : torrents) updateTorrentStatus(torrent); diff --git a/src/gui/transferlistfilters/statusfilterwidget.h b/src/gui/transferlistfilters/statusfilterwidget.h index c3c3b3229..ac1bbd5a5 100644 --- a/src/gui/transferlistfilters/statusfilterwidget.h +++ b/src/gui/transferlistfilters/statusfilterwidget.h @@ -58,7 +58,7 @@ private: void configure(); - void update(QVector torrents); + void update(const QVector &torrents); void updateTorrentStatus(const BitTorrent::Torrent *torrent); void updateTexts(); void hideZeroItems(); diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index f04cbc962..e49bb7df1 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -149,7 +149,7 @@ void AppController::preferencesAction() QJsonObject nativeDirs; for (auto i = watchedFolders.cbegin(); i != watchedFolders.cend(); ++i) { - const Path watchedFolder = i.key(); + const Path &watchedFolder = i.key(); const BitTorrent::AddTorrentParams params = i.value().addTorrentParams; if (params.savePath.isEmpty()) nativeDirs.insert(watchedFolder.toString(), 1);