From abf8c179fc1cf204bf0d1e4eb40c9c8a528c393d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=BE=D0=BD=D1=81=D1=82=D0=B0=D0=BD=D1=82=D0=B8?= =?UTF-8?q?=D0=BD=20=D0=93=D0=BE=D0=BD=D1=87=D0=B0=D1=80=D0=B8=D0=BA?= Date: Fri, 13 Jul 2012 21:48:19 +0300 Subject: [PATCH] Use preincrement for iterators instead of postincrement --- src/fs_utils.cpp | 2 +- src/properties/peerlistwidget.cpp | 2 +- src/properties/trackerlist.cpp | 2 +- src/properties/trackersadditiondlg.h | 2 +- src/qtlibtorrent/qbtsession.cpp | 34 ++++++++++++------------ src/qtlibtorrent/qtorrenthandle.cpp | 4 +-- src/qtlibtorrent/torrentmodel.cpp | 6 ++--- src/qtlibtorrent/torrentspeedmonitor.cpp | 2 +- src/torrentpersistentdata.h | 2 +- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/fs_utils.cpp b/src/fs_utils.cpp index 249a1e4df..e9af3777f 100644 --- a/src/fs_utils.cpp +++ b/src/fs_utils.cpp @@ -215,7 +215,7 @@ QString fsutils::fixFileNames(const QString& path) if (parts.isEmpty()) return path; QByteArray last_part = parts.takeLast(); QList::iterator it; - for (it = parts.begin(); it != parts.end(); it++) { + for (it = parts.begin(); it != parts.end(); ++it) { // Make sure the filename is not too long if (it->size() > MAX_FILENAME_BYTES) { qWarning() << "Folder" << *it << "was cut because it was too long"; diff --git a/src/properties/peerlistwidget.cpp b/src/properties/peerlistwidget.cpp index fd4c5b9b5..6084d16a2 100644 --- a/src/properties/peerlistwidget.cpp +++ b/src/properties/peerlistwidget.cpp @@ -312,7 +312,7 @@ void PeerListWidget::loadPeers(const QTorrentHandle &h, bool force_hostname_reso h.get_peer_info(peers); std::vector::const_iterator itr; QSet old_peers_set = m_peerItems.keys().toSet(); - for (itr = peers.begin(); itr != peers.end(); itr++) { + for (itr = peers.begin(); itr != peers.end(); ++itr) { peer_info peer = *itr; QString peer_ip = misc::toQString(peer.ip.address().to_string(ec)); if (ec) continue; diff --git a/src/properties/trackerlist.cpp b/src/properties/trackerlist.cpp index 90837081c..c11d24b41 100644 --- a/src/properties/trackerlist.cpp +++ b/src/properties/trackerlist.cpp @@ -313,7 +313,7 @@ void TrackerList::deleteSelectedTrackers() { std::vector remaining_trackers; std::vector trackers = h.trackers(); std::vector::iterator it; - for (it = trackers.begin(); it != trackers.end(); it++) { + for (it = trackers.begin(); it != trackers.end(); ++it) { if (!urls_to_remove.contains(misc::toQString((*it).url))) { remaining_trackers.push_back(*it); } diff --git a/src/properties/trackersadditiondlg.h b/src/properties/trackersadditiondlg.h index 70e80d1ff..caa145c55 100644 --- a/src/properties/trackersadditiondlg.h +++ b/src/properties/trackersadditiondlg.h @@ -90,7 +90,7 @@ public slots: std::vector::iterator itr = tor_trackers.begin(); while(itr != tor_trackers.end()) { existingTrackers << QUrl(misc::toQString(itr->url)); - itr++; + ++itr; } // Load from current user list QStringList tmp = trackers_list->toPlainText().split("\n"); diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index 815262ba6..3b4d057d6 100644 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -213,7 +213,7 @@ void QBtSession::processBigRatios() { qDebug("Process big ratios..."); std::vector torrents = s->get_torrents(); std::vector::iterator torrentIT; - for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { + for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) { const QTorrentHandle h(*torrentIT); if (!h.is_valid()) continue; if (h.is_seed()) { @@ -360,7 +360,7 @@ void QBtSession::configureSession() { // Update torrent handles std::vector torrents = s->get_torrents(); std::vector::iterator torrentIT; - for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { + for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) { QTorrentHandle h = QTorrentHandle(*torrentIT); if (h.is_valid()) h.resolve_countries(resolve_countries); @@ -712,7 +712,7 @@ QTorrentHandle QBtSession::getTorrentHandle(const QString &hash) const { bool QBtSession::hasActiveTorrents() const { std::vector torrents = s->get_torrents(); std::vector::iterator torrentIT; - for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { + for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) { const QTorrentHandle h(*torrentIT); if (h.is_valid() && !h.is_paused() && !h.is_queued()) return true; @@ -723,7 +723,7 @@ bool QBtSession::hasActiveTorrents() const { bool QBtSession::hasDownloadingTorrents() const { std::vector torrents = s->get_torrents(); std::vector::iterator torrentIT; - for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { + for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) { if (torrentIT->is_valid()) { try { const torrent_status::state_t state = torrentIT->status().state; @@ -803,7 +803,7 @@ void QBtSession::deleteTorrent(const QString &hash, bool delete_local_files) { void QBtSession::pauseAllTorrents() { std::vector torrents = s->get_torrents(); std::vector::iterator torrentIT; - for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { + for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) { try { QTorrentHandle h = QTorrentHandle(*torrentIT); if (!h.is_paused()) { @@ -821,7 +821,7 @@ std::vector QBtSession::getTorrents() const { void QBtSession::resumeAllTorrents() { std::vector torrents = s->get_torrents(); std::vector::iterator torrentIT; - for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { + for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) { try { QTorrentHandle h = QTorrentHandle(*torrentIT); if (h.is_paused()) { @@ -1335,7 +1335,7 @@ void QBtSession::mergeTorrents(QTorrentHandle &h_ex, boost::intrusive_ptr new_urlseeds = t->url_seeds(); std::vector::iterator it; - for (it = new_urlseeds.begin(); it != new_urlseeds.end(); it++) { + for (it = new_urlseeds.begin(); it != new_urlseeds.end(); ++it) { const QString new_url = misc::toQString(it->c_str()); if (!old_urlseeds.contains(new_url)) { urlseeds_added = true; @@ -1359,7 +1359,7 @@ void QBtSession::exportTorrentFiles(QString path) { QDir torrentBackup(fsutils::BTBackupLocation()); std::vector handles = s->get_torrents(); std::vector::iterator itr; - for (itr=handles.begin(); itr != handles.end(); itr++) { + for (itr=handles.begin(); itr != handles.end(); ++itr) { const QTorrentHandle h(*itr); if (!h.is_valid()) { std::cerr << "Torrent Export: torrent is invalid, skipping..." << std::endl; @@ -1400,7 +1400,7 @@ void QBtSession::setMaxConnectionsPerTorrent(int max) { // Apply this to all session torrents std::vector handles = s->get_torrents(); std::vector::const_iterator it; - for (it = handles.begin(); it != handles.end(); it++) { + for (it = handles.begin(); it != handles.end(); ++it) { if (!it->is_valid()) continue; try { @@ -1414,7 +1414,7 @@ void QBtSession::setMaxUploadsPerTorrent(int max) { // Apply this to all session torrents std::vector handles = s->get_torrents(); std::vector::const_iterator it; - for (it = handles.begin(); it != handles.end(); it++) { + for (it = handles.begin(); it != handles.end(); ++it) { if (!it->is_valid()) continue; try { @@ -1565,7 +1565,7 @@ qreal QBtSession::getRealRatio(const QString &hash) const { void QBtSession::saveTempFastResumeData() { std::vector torrents = s->get_torrents(); std::vector::iterator torrentIT; - for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { + for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) { QTorrentHandle h = QTorrentHandle(*torrentIT); try { if (!h.is_valid() || !h.has_metadata() /*|| h.is_seed() || h.is_paused()*/) continue; @@ -1591,7 +1591,7 @@ void QBtSession::saveFastResumeData() { s->pause(); std::vector torrents = s->get_torrents(); std::vector::iterator torrentIT; - for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { + for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) { QTorrentHandle h = QTorrentHandle(*torrentIT); if (!h.is_valid() || !h.has_metadata()) continue; try { @@ -1727,7 +1727,7 @@ void QBtSession::setDefaultTempPath(QString temppath) { // Moving all torrents to their destination folder std::vector torrents = s->get_torrents(); std::vector::iterator torrentIT; - for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { + for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) { QTorrentHandle h = QTorrentHandle(*torrentIT); if (!h.is_valid()) continue; h.move_storage(getSavePath(h.hash())); @@ -1737,7 +1737,7 @@ void QBtSession::setDefaultTempPath(QString temppath) { // Moving all downloading torrents to temporary save path std::vector torrents = s->get_torrents(); std::vector::iterator torrentIT; - for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { + for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) { QTorrentHandle h = QTorrentHandle(*torrentIT); if (!h.is_valid()) continue; if (!h.is_seed()) { @@ -1812,7 +1812,7 @@ void QBtSession::setAppendLabelToSavePath(bool append) { // Move torrents storage to sub folder with label name std::vector torrents = s->get_torrents(); std::vector::iterator torrentIT; - for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { + for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) { QTorrentHandle h = QTorrentHandle(*torrentIT); appendLabelToTorrentSavePath(h); } @@ -1826,7 +1826,7 @@ void QBtSession::setAppendqBExtension(bool append) { // append or remove .!qB extension for incomplete files std::vector torrents = s->get_torrents(); std::vector::iterator torrentIT; - for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { + for (torrentIT = torrents.begin(); torrentIT != torrents.end(); ++torrentIT) { QTorrentHandle h = QTorrentHandle(*torrentIT); appendqBextensionToTorrent(h, appendqBExtension); } @@ -2474,7 +2474,7 @@ void QBtSession::readAlerts() { // Force reannounce on all torrents because some trackers blacklist some ports std::vector torrents = s->get_torrents(); std::vector::iterator it; - for (it = torrents.begin(); it != torrents.end(); it++) { + for (it = torrents.begin(); it != torrents.end(); ++it) { it->force_reannounce(); } emit listenSucceeded(); diff --git a/src/qtlibtorrent/qtorrenthandle.cpp b/src/qtlibtorrent/qtorrenthandle.cpp index bf6961d84..8d91cb352 100644 --- a/src/qtlibtorrent/qtorrenthandle.cpp +++ b/src/qtlibtorrent/qtorrenthandle.cpp @@ -282,7 +282,7 @@ QStringList QTorrentHandle::url_seeds() const { try { const std::set existing_seeds = torrent_handle::url_seeds(); std::set::const_iterator it; - for (it = existing_seeds.begin(); it != existing_seeds.end(); it++) { + for (it = existing_seeds.begin(); it != existing_seeds.end(); ++it) { qDebug("URL Seed: %s", it->c_str()); res << misc::toQString(*it); } @@ -582,7 +582,7 @@ QString QTorrentHandle::error() const { void QTorrentHandle::downloading_pieces(bitfield &bf) const { std::vector queue; torrent_handle::get_download_queue(queue); - for (std::vector::const_iterator it=queue.begin(); it!= queue.end(); it++) { + for (std::vector::const_iterator it=queue.begin(); it!= queue.end(); ++it) { bf.set_bit(it->piece_index); } return; diff --git a/src/qtlibtorrent/torrentmodel.cpp b/src/qtlibtorrent/torrentmodel.cpp index 139aee9bc..aa0b8932b 100644 --- a/src/qtlibtorrent/torrentmodel.cpp +++ b/src/qtlibtorrent/torrentmodel.cpp @@ -206,7 +206,7 @@ void TorrentModel::populate() { // Load the torrents std::vector torrents = QBtSession::instance()->getSession()->get_torrents(); std::vector::const_iterator it; - for (it = torrents.begin(); it != torrents.end(); it++) { + for (it = torrents.begin(); it != torrents.end(); ++it) { addTorrent(QTorrentHandle(*it)); } // Refresh timer @@ -315,7 +315,7 @@ int TorrentModel::torrentRow(const QString &hash) const { QList::const_iterator it; int row = 0; - for (it = m_torrents.constBegin(); it != m_torrents.constEnd(); it++) { + for (it = m_torrents.constBegin(); it != m_torrents.constEnd(); ++it) { if ((*it)->hash() == hash) return row; ++row; } @@ -396,7 +396,7 @@ TorrentStatusReport TorrentModel::getTorrentStatusReport() const { TorrentStatusReport report; QList::const_iterator it; - for (it = m_torrents.constBegin(); it != m_torrents.constEnd(); it++) { + for (it = m_torrents.constBegin(); it != m_torrents.constEnd(); ++it) { switch((*it)->data(TorrentModelItem::TR_STATUS).toInt()) { case TorrentModelItem::STATE_DOWNLOADING: ++report.nb_active; diff --git a/src/qtlibtorrent/torrentspeedmonitor.cpp b/src/qtlibtorrent/torrentspeedmonitor.cpp index 561925bdd..969074d77 100644 --- a/src/qtlibtorrent/torrentspeedmonitor.cpp +++ b/src/qtlibtorrent/torrentspeedmonitor.cpp @@ -123,7 +123,7 @@ void TorrentSpeedMonitor::getSamples() { const std::vector torrents = m_session->getSession()->get_torrents(); std::vector::const_iterator it; - for (it = torrents.begin(); it != torrents.end(); it++) { + for (it = torrents.begin(); it != torrents.end(); ++it) { try { #if LIBTORRENT_VERSION_MINOR > 15 torrent_status st = it->status(0x0); diff --git a/src/torrentpersistentdata.h b/src/torrentpersistentdata.h index 4cc88c6c2..274f730b1 100644 --- a/src/torrentpersistentdata.h +++ b/src/torrentpersistentdata.h @@ -67,7 +67,7 @@ public: QStringList pieces_priority; while(pp_it != pp.end()) { pieces_priority << QString::number(*pp_it); - pp_it++; + ++pp_it; } data["files_priority"] = pieces_priority; all_data[hash] = data;