Convert pass-by-value arguments to const refs where applicable

This commit is contained in:
thalieht
2019-02-12 02:45:30 +02:00
parent ca3ce87e06
commit 445adb0ab4
18 changed files with 84 additions and 84 deletions

View File

@@ -43,7 +43,7 @@ PeerAddress::PeerAddress()
{
}
PeerAddress::PeerAddress(QHostAddress ip, ushort port)
PeerAddress::PeerAddress(const QHostAddress &ip, ushort port)
: ip(ip)
, port(port)
{

View File

@@ -45,7 +45,7 @@ namespace BitTorrent
ushort port;
PeerAddress();
PeerAddress(QHostAddress ip, ushort port);
PeerAddress(const QHostAddress &ip, ushort port);
};
class PeerInfo

View File

@@ -3762,7 +3762,7 @@ void Session::readAlerts()
handleAlert(a);
}
void Session::handleAlert(libt::alert *a)
void Session::handleAlert(const libt::alert *a)
{
try {
switch (a->type()) {
@@ -3784,53 +3784,53 @@ void Session::handleAlert(libt::alert *a)
dispatchTorrentAlert(a);
break;
case libt::metadata_received_alert::alert_type:
handleMetadataReceivedAlert(static_cast<libt::metadata_received_alert*>(a));
handleMetadataReceivedAlert(static_cast<const libt::metadata_received_alert*>(a));
dispatchTorrentAlert(a);
break;
case libt::state_update_alert::alert_type:
handleStateUpdateAlert(static_cast<libt::state_update_alert*>(a));
handleStateUpdateAlert(static_cast<const libt::state_update_alert*>(a));
break;
case libt::session_stats_alert::alert_type:
handleSessionStatsAlert(static_cast<libt::session_stats_alert*>(a));
handleSessionStatsAlert(static_cast<const libt::session_stats_alert*>(a));
break;
case libt::file_error_alert::alert_type:
handleFileErrorAlert(static_cast<libt::file_error_alert*>(a));
handleFileErrorAlert(static_cast<const libt::file_error_alert*>(a));
break;
case libt::add_torrent_alert::alert_type:
handleAddTorrentAlert(static_cast<libt::add_torrent_alert*>(a));
handleAddTorrentAlert(static_cast<const libt::add_torrent_alert*>(a));
break;
case libt::torrent_removed_alert::alert_type:
handleTorrentRemovedAlert(static_cast<libt::torrent_removed_alert*>(a));
handleTorrentRemovedAlert(static_cast<const libt::torrent_removed_alert*>(a));
break;
case libt::torrent_deleted_alert::alert_type:
handleTorrentDeletedAlert(static_cast<libt::torrent_deleted_alert*>(a));
handleTorrentDeletedAlert(static_cast<const libt::torrent_deleted_alert*>(a));
break;
case libt::torrent_delete_failed_alert::alert_type:
handleTorrentDeleteFailedAlert(static_cast<libt::torrent_delete_failed_alert*>(a));
handleTorrentDeleteFailedAlert(static_cast<const libt::torrent_delete_failed_alert*>(a));
break;
case libt::portmap_error_alert::alert_type:
handlePortmapWarningAlert(static_cast<libt::portmap_error_alert*>(a));
handlePortmapWarningAlert(static_cast<const libt::portmap_error_alert*>(a));
break;
case libt::portmap_alert::alert_type:
handlePortmapAlert(static_cast<libt::portmap_alert*>(a));
handlePortmapAlert(static_cast<const libt::portmap_alert*>(a));
break;
case libt::peer_blocked_alert::alert_type:
handlePeerBlockedAlert(static_cast<libt::peer_blocked_alert*>(a));
handlePeerBlockedAlert(static_cast<const libt::peer_blocked_alert*>(a));
break;
case libt::peer_ban_alert::alert_type:
handlePeerBanAlert(static_cast<libt::peer_ban_alert*>(a));
handlePeerBanAlert(static_cast<const libt::peer_ban_alert*>(a));
break;
case libt::url_seed_alert::alert_type:
handleUrlSeedAlert(static_cast<libt::url_seed_alert*>(a));
handleUrlSeedAlert(static_cast<const libt::url_seed_alert*>(a));
break;
case libt::listen_succeeded_alert::alert_type:
handleListenSucceededAlert(static_cast<libt::listen_succeeded_alert*>(a));
handleListenSucceededAlert(static_cast<const libt::listen_succeeded_alert*>(a));
break;
case libt::listen_failed_alert::alert_type:
handleListenFailedAlert(static_cast<libt::listen_failed_alert*>(a));
handleListenFailedAlert(static_cast<const libt::listen_failed_alert*>(a));
break;
case libt::external_ip_alert::alert_type:
handleExternalIPAlert(static_cast<libt::external_ip_alert*>(a));
handleExternalIPAlert(static_cast<const libt::external_ip_alert*>(a));
break;
}
}
@@ -3839,7 +3839,7 @@ void Session::handleAlert(libt::alert *a)
}
}
void Session::dispatchTorrentAlert(libt::alert *a)
void Session::dispatchTorrentAlert(const libt::alert *a)
{
TorrentHandle *const torrent = m_torrents.value(static_cast<const libt::torrent_alert*>(a)->handle.info_hash());
if (torrent)
@@ -3901,7 +3901,7 @@ void Session::createTorrentHandle(const libt::torrent_handle &nativeHandle)
emit torrentNew(torrent);
}
void Session::handleAddTorrentAlert(libt::add_torrent_alert *p)
void Session::handleAddTorrentAlert(const libt::add_torrent_alert *p)
{
if (p->error) {
qDebug("/!\\ Error: Failed to add torrent!");
@@ -3914,7 +3914,7 @@ void Session::handleAddTorrentAlert(libt::add_torrent_alert *p)
}
}
void Session::handleTorrentRemovedAlert(libt::torrent_removed_alert *p)
void Session::handleTorrentRemovedAlert(const libt::torrent_removed_alert *p)
{
const InfoHash infoHash {p->info_hash};
@@ -3930,7 +3930,7 @@ void Session::handleTorrentRemovedAlert(libt::torrent_removed_alert *p)
}
}
void Session::handleTorrentDeletedAlert(libt::torrent_deleted_alert *p)
void Session::handleTorrentDeletedAlert(const libt::torrent_deleted_alert *p)
{
const InfoHash infoHash {p->info_hash};
@@ -3942,7 +3942,7 @@ void Session::handleTorrentDeletedAlert(libt::torrent_deleted_alert *p)
LogMsg(tr("'%1' was removed from the transfer list and hard disk.", "'xxx.avi' was removed...").arg(tmpRemovingTorrentData.name));
}
void Session::handleTorrentDeleteFailedAlert(libt::torrent_delete_failed_alert *p)
void Session::handleTorrentDeleteFailedAlert(const libt::torrent_delete_failed_alert *p)
{
const InfoHash infoHash {p->info_hash};
@@ -3958,7 +3958,7 @@ void Session::handleTorrentDeleteFailedAlert(libt::torrent_delete_failed_alert *
, Log::CRITICAL);
}
void Session::handleMetadataReceivedAlert(libt::metadata_received_alert *p)
void Session::handleMetadataReceivedAlert(const libt::metadata_received_alert *p)
{
const InfoHash hash {p->handle.info_hash()};
@@ -3970,7 +3970,7 @@ void Session::handleMetadataReceivedAlert(libt::metadata_received_alert *p)
}
}
void Session::handleFileErrorAlert(libt::file_error_alert *p)
void Session::handleFileErrorAlert(const libt::file_error_alert *p)
{
qDebug() << Q_FUNC_INFO;
// NOTE: Check this function!
@@ -3988,18 +3988,18 @@ void Session::handleFileErrorAlert(libt::file_error_alert *p)
}
}
void Session::handlePortmapWarningAlert(libt::portmap_error_alert *p)
void Session::handlePortmapWarningAlert(const libt::portmap_error_alert *p)
{
Logger::instance()->addMessage(tr("UPnP/NAT-PMP: Port mapping failure, message: %1").arg(QString::fromStdString(p->message())), Log::CRITICAL);
}
void Session::handlePortmapAlert(libt::portmap_alert *p)
void Session::handlePortmapAlert(const libt::portmap_alert *p)
{
qDebug("UPnP Success, msg: %s", p->message().c_str());
Logger::instance()->addMessage(tr("UPnP/NAT-PMP: Port mapping successful, message: %1").arg(QString::fromStdString(p->message())), Log::INFO);
}
void Session::handlePeerBlockedAlert(libt::peer_blocked_alert *p)
void Session::handlePeerBlockedAlert(const libt::peer_blocked_alert *p)
{
boost::system::error_code ec;
const std::string ip = p->ip.to_string(ec);
@@ -4029,7 +4029,7 @@ void Session::handlePeerBlockedAlert(libt::peer_blocked_alert *p)
Logger::instance()->addPeer(QString::fromLatin1(ip.c_str()), true, reason);
}
void Session::handlePeerBanAlert(libt::peer_ban_alert *p)
void Session::handlePeerBanAlert(const libt::peer_ban_alert *p)
{
boost::system::error_code ec;
const std::string ip = p->ip.address().to_string(ec);
@@ -4037,14 +4037,14 @@ void Session::handlePeerBanAlert(libt::peer_ban_alert *p)
Logger::instance()->addPeer(QString::fromLatin1(ip.c_str()), false);
}
void Session::handleUrlSeedAlert(libt::url_seed_alert *p)
void Session::handleUrlSeedAlert(const libt::url_seed_alert *p)
{
Logger::instance()->addMessage(tr("URL seed lookup failed for URL: '%1', message: %2")
.arg(QString::fromStdString(p->server_url()))
.arg(QString::fromStdString(p->message())), Log::CRITICAL);
}
void Session::handleListenSucceededAlert(libt::listen_succeeded_alert *p)
void Session::handleListenSucceededAlert(const libt::listen_succeeded_alert *p)
{
boost::system::error_code ec;
QString proto = "TCP";
@@ -4067,7 +4067,7 @@ void Session::handleListenSucceededAlert(libt::listen_succeeded_alert *p)
it->force_reannounce();
}
void Session::handleListenFailedAlert(libt::listen_failed_alert *p)
void Session::handleListenFailedAlert(const libt::listen_failed_alert *p)
{
boost::system::error_code ec;
QString proto = "TCP";
@@ -4090,13 +4090,13 @@ void Session::handleListenFailedAlert(libt::listen_failed_alert *p)
, Log::CRITICAL);
}
void Session::handleExternalIPAlert(libt::external_ip_alert *p)
void Session::handleExternalIPAlert(const libt::external_ip_alert *p)
{
boost::system::error_code ec;
Logger::instance()->addMessage(tr("External IP: %1", "e.g. External IP: 192.168.0.1").arg(p->external_address.to_string(ec).c_str()), Log::INFO);
}
void Session::handleSessionStatsAlert(libt::session_stats_alert *p)
void Session::handleSessionStatsAlert(const libt::session_stats_alert *p)
{
const qreal interval = m_statsUpdateTimer.restart() / 1000.;
@@ -4161,7 +4161,7 @@ void Session::handleSessionStatsAlert(libt::session_stats_alert *p)
emit statsUpdated();
}
void Session::handleStateUpdateAlert(libt::state_update_alert *p)
void Session::handleStateUpdateAlert(const libt::state_update_alert *p)
{
for (const libt::torrent_status &status : p->status) {
TorrentHandle *const torrent = m_torrents.value(status.info_hash);

View File

@@ -589,24 +589,24 @@ namespace BitTorrent
void exportTorrentFile(TorrentHandle *const torrent, TorrentExportFolder folder = TorrentExportFolder::Regular);
void saveTorrentResumeData(TorrentHandle *const torrent);
void handleAlert(libtorrent::alert *a);
void dispatchTorrentAlert(libtorrent::alert *a);
void handleAddTorrentAlert(libtorrent::add_torrent_alert *p);
void handleStateUpdateAlert(libtorrent::state_update_alert *p);
void handleMetadataReceivedAlert(libtorrent::metadata_received_alert *p);
void handleFileErrorAlert(libtorrent::file_error_alert *p);
void handleTorrentRemovedAlert(libtorrent::torrent_removed_alert *p);
void handleTorrentDeletedAlert(libtorrent::torrent_deleted_alert *p);
void handleTorrentDeleteFailedAlert(libtorrent::torrent_delete_failed_alert *p);
void handlePortmapWarningAlert(libtorrent::portmap_error_alert *p);
void handlePortmapAlert(libtorrent::portmap_alert *p);
void handlePeerBlockedAlert(libtorrent::peer_blocked_alert *p);
void handlePeerBanAlert(libtorrent::peer_ban_alert *p);
void handleUrlSeedAlert(libtorrent::url_seed_alert *p);
void handleListenSucceededAlert(libtorrent::listen_succeeded_alert *p);
void handleListenFailedAlert(libtorrent::listen_failed_alert *p);
void handleExternalIPAlert(libtorrent::external_ip_alert *p);
void handleSessionStatsAlert(libtorrent::session_stats_alert *p);
void handleAlert(const libtorrent::alert *a);
void dispatchTorrentAlert(const libtorrent::alert *a);
void handleAddTorrentAlert(const libtorrent::add_torrent_alert *p);
void handleStateUpdateAlert(const libtorrent::state_update_alert *p);
void handleMetadataReceivedAlert(const libtorrent::metadata_received_alert *p);
void handleFileErrorAlert(const libtorrent::file_error_alert *p);
void handleTorrentRemovedAlert(const libtorrent::torrent_removed_alert *p);
void handleTorrentDeletedAlert(const libtorrent::torrent_deleted_alert *p);
void handleTorrentDeleteFailedAlert(const libtorrent::torrent_delete_failed_alert *p);
void handlePortmapWarningAlert(const libtorrent::portmap_error_alert *p);
void handlePortmapAlert(const libtorrent::portmap_alert *p);
void handlePeerBlockedAlert(const libtorrent::peer_blocked_alert *p);
void handlePeerBanAlert(const libtorrent::peer_ban_alert *p);
void handleUrlSeedAlert(const libtorrent::url_seed_alert *p);
void handleListenSucceededAlert(const libtorrent::listen_succeeded_alert *p);
void handleListenFailedAlert(const libtorrent::listen_failed_alert *p);
void handleExternalIPAlert(const libtorrent::external_ip_alert *p);
void handleSessionStatsAlert(const libtorrent::session_stats_alert *p);
void createTorrentHandle(const libtorrent::torrent_handle &nativeHandle);

View File

@@ -1717,7 +1717,7 @@ void TorrentHandle::handleAppendExtensionToggled()
manageIncompleteFiles();
}
void TorrentHandle::handleAlert(libtorrent::alert *a)
void TorrentHandle::handleAlert(const libtorrent::alert *a)
{
switch (a->type()) {
case libt::stats_alert::alert_type:

View File

@@ -358,7 +358,7 @@ namespace BitTorrent
// Session interface
libtorrent::torrent_handle nativeHandle() const;
void handleAlert(libtorrent::alert *a);
void handleAlert(const libtorrent::alert *a);
void handleStateUpdate(const libtorrent::torrent_status &nativeStatus);
void handleTempPathChanged();
void handleCategorySavePathChanged();

View File

@@ -533,7 +533,7 @@ void SearchPluginManager::parseVersionInfo(const QByteArray &info)
}
}
bool SearchPluginManager::isUpdateNeeded(QString pluginName, PluginVersion newVersion) const
bool SearchPluginManager::isUpdateNeeded(const QString &pluginName, PluginVersion newVersion) const
{
PluginInfo *plugin = pluginInfo(pluginName);
if (!plugin) return true;

View File

@@ -102,7 +102,7 @@ private:
void updateNova();
void parseVersionInfo(const QByteArray &info);
void installPlugin_impl(const QString &name, const QString &path);
bool isUpdateNeeded(QString pluginName, PluginVersion newVersion) const;
bool isUpdateNeeded(const QString &pluginName, PluginVersion newVersion) const;
void versionInfoDownloaded(const QString &url, const QByteArray &data);
void versionInfoDownloadFailed(const QString &url, const QString &reason);