From 56766dc08b225b86597b6e6823965df95b5ac7ca Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 21 Jul 2018 15:07:11 +0800 Subject: [PATCH] Avoid binding constant reference to returned object In such cases, it makes no sense doing so. --- src/base/bittorrent/peerinfo.cpp | 4 ++-- src/base/net/reverseresolution.cpp | 4 ++-- src/base/scanfoldersmodel.cpp | 10 +++++----- src/gui/addnewtorrentdialog.cpp | 4 ++-- src/gui/properties/propertieswidget.cpp | 2 +- src/gui/transferlistfilterswidget.cpp | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/base/bittorrent/peerinfo.cpp b/src/base/bittorrent/peerinfo.cpp index 3db80ceb2..6d5deb46a 100644 --- a/src/base/bittorrent/peerinfo.cpp +++ b/src/base/bittorrent/peerinfo.cpp @@ -246,8 +246,8 @@ QString PeerInfo::connectionType() const void PeerInfo::calcRelevance(const TorrentHandle *torrent) { - const QBitArray &allPieces = torrent->pieces(); - const QBitArray &peerPieces = pieces(); + const QBitArray allPieces = torrent->pieces(); + const QBitArray peerPieces = pieces(); int localMissing = 0; int remoteHaves = 0; diff --git a/src/base/net/reverseresolution.cpp b/src/base/net/reverseresolution.cpp index 15c593776..058f444f9 100644 --- a/src/base/net/reverseresolution.cpp +++ b/src/base/net/reverseresolution.cpp @@ -75,7 +75,7 @@ void ReverseResolution::resolve(const QString &ip) void ReverseResolution::hostResolved(const QHostInfo &host) { - const QString &ip = m_lookups.take(host.lookupId()); + const QString ip = m_lookups.take(host.lookupId()); Q_ASSERT(!ip.isNull()); if (host.error() != QHostInfo::NoError) { @@ -83,7 +83,7 @@ void ReverseResolution::hostResolved(const QHostInfo &host) return; } - const QString &hostname = host.hostName(); + const QString hostname = host.hostName(); qDebug() << Q_FUNC_INFO << ip << QString("->") << hostname; m_cache.insert(ip, new QString(hostname)); diff --git a/src/base/scanfoldersmodel.cpp b/src/base/scanfoldersmodel.cpp index 74c9dc952..a5b00dbbf 100644 --- a/src/base/scanfoldersmodel.cpp +++ b/src/base/scanfoldersmodel.cpp @@ -212,11 +212,11 @@ ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &watchPath, if (!watchDir.exists()) return DoesNotExist; if (!watchDir.isReadable()) return CannotRead; - const QString &canonicalWatchPath = watchDir.canonicalPath(); + const QString canonicalWatchPath = watchDir.canonicalPath(); if (findPathData(canonicalWatchPath) != -1) return AlreadyInList; QDir downloadDir(downloadPath); - const QString &canonicalDownloadPath = downloadDir.canonicalPath(); + const QString canonicalDownloadPath = downloadDir.canonicalPath(); if (!m_fsWatcher) { m_fsWatcher = new FileSystemWatcher(this); @@ -236,12 +236,12 @@ ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &watchPath, ScanFoldersModel::PathStatus ScanFoldersModel::updatePath(const QString &watchPath, const PathType &downloadType, const QString &downloadPath) { QDir watchDir(watchPath); - const QString &canonicalWatchPath = watchDir.canonicalPath(); + const QString canonicalWatchPath = watchDir.canonicalPath(); int row = findPathData(canonicalWatchPath); if (row == -1) return DoesNotExist; QDir downloadDir(downloadPath); - const QString &canonicalDownloadPath = downloadDir.canonicalPath(); + const QString canonicalDownloadPath = downloadDir.canonicalPath(); m_pathList.at(row)->downloadType = downloadType; m_pathList.at(row)->downloadPath = Utils::Fs::toNativePath(canonicalDownloadPath); @@ -256,7 +256,7 @@ void ScanFoldersModel::addToFSWatcher(const QStringList &watchPaths) foreach (const QString &path, watchPaths) { QDir watchDir(path); - const QString &canonicalWatchPath = watchDir.canonicalPath(); + const QString canonicalWatchPath = watchDir.canonicalPath(); m_fsWatcher->addPath(canonicalWatchPath); } } diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index 30dc31d97..cb6cdf420 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -551,7 +551,7 @@ void AddNewTorrentDialog::renameSelectedFile() if (!newPath.endsWith('/')) newPath += '/'; // Check for overwriting for (int i = 0; i < m_torrentInfo.filesCount(); ++i) { - const QString ¤tName = m_torrentInfo.filePath(i); + const QString currentName = m_torrentInfo.filePath(i); #if defined(Q_OS_UNIX) || defined(Q_WS_QWS) if (currentName.startsWith(newPath, Qt::CaseSensitive)) { #else @@ -565,7 +565,7 @@ void AddNewTorrentDialog::renameSelectedFile() } // Replace path in all files for (int i = 0; i < m_torrentInfo.filesCount(); ++i) { - const QString ¤tName = m_torrentInfo.filePath(i); + const QString currentName = m_torrentInfo.filePath(i); if (currentName.startsWith(oldPath)) { QString newName = currentName; newName.replace(0, oldPath.length(), newPath); diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index 2a19a600f..fadcc3675 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -751,7 +751,7 @@ void PropertiesWidget::renameSelectedFile() if (!newPath.endsWith('/')) newPath += '/'; // Check for overwriting for (int i = 0; i < m_torrent->filesCount(); ++i) { - const QString ¤tName = m_torrent->filePath(i); + const QString currentName = m_torrent->filePath(i); #if defined(Q_OS_UNIX) || defined(Q_WS_QWS) if (currentName.startsWith(newPath, Qt::CaseSensitive)) { #else diff --git a/src/gui/transferlistfilterswidget.cpp b/src/gui/transferlistfilterswidget.cpp index 5857ff9b7..6613c68f0 100644 --- a/src/gui/transferlistfilterswidget.cpp +++ b/src/gui/transferlistfilterswidget.cpp @@ -515,7 +515,7 @@ void TrackerFiltersList::torrentAboutToBeDeleted(BitTorrent::TorrentHandle *cons QString TrackerFiltersList::trackerFromRow(int row) const { Q_ASSERT(row > 1); - const QString &tracker = item(row)->text(); + const QString tracker = item(row)->text(); QStringList parts = tracker.split(' '); Q_ASSERT(parts.size() >= 2); parts.removeLast(); // Remove trailing number