From 947c7e1d644aa98d5796b8822157c07a50b58f56 Mon Sep 17 00:00:00 2001 From: thalieht Date: Wed, 13 Feb 2019 16:45:54 +0200 Subject: [PATCH] Convert to range-based for loop --- src/gui/properties/trackerlistwidget.cpp | 3 +-- src/webui/webapplication.cpp | 10 +++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/gui/properties/trackerlistwidget.cpp b/src/gui/properties/trackerlistwidget.cpp index 1af932331..207738cdd 100644 --- a/src/gui/properties/trackerlistwidget.cpp +++ b/src/gui/properties/trackerlistwidget.cpp @@ -466,8 +466,7 @@ void TrackerListWidget::editSelectedTracker() QList trackers = torrent->trackers(); bool match = false; - for (int i = 0; i < trackers.size(); ++i) { - BitTorrent::TrackerEntry &entry = trackers[i]; + for (auto &entry : trackers) { if (newTrackerURL == QUrl(entry.url())) { QMessageBox::warning(this, tr("Tracker editing failed"), tr("The tracker URL already exists.")); return; diff --git a/src/webui/webapplication.cpp b/src/webui/webapplication.cpp index fffc9a32f..a0e219753 100644 --- a/src/webui/webapplication.cpp +++ b/src/webui/webapplication.cpp @@ -509,13 +509,9 @@ QString WebApplication::generateSid() const QString sid; do { - const size_t size = 6; - quint32 tmp[size]; - - for (size_t i = 0; i < size; ++i) - tmp[i] = Utils::Random::rand(); - - sid = QByteArray::fromRawData(reinterpret_cast(tmp), sizeof(quint32) * size).toBase64(); + const quint32 tmp[] = {Utils::Random::rand(), Utils::Random::rand(), Utils::Random::rand() + , Utils::Random::rand(), Utils::Random::rand(), Utils::Random::rand()}; + sid = QByteArray::fromRawData(reinterpret_cast(tmp), sizeof(tmp)).toBase64(); } while (m_sessions.contains(sid));