From d993684fec07ccf6c3135e16286cd87e045f142c Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 15 Jul 2014 14:43:20 -0300 Subject: Do not create a backup for Q_FOREACH container Q_FOREACH will expand and already creates a copy of the contained container, so this is just a waste of cpu cycles and also increases a tiny bit the memory consumption. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/divelistview.cpp | 3 +-- qt-ui/divepicturewidget.cpp | 3 +-- qt-ui/maintab.cpp | 3 +-- qt-ui/models.cpp | 3 +-- qt-ui/preferences.cpp | 3 +-- qt-ui/profile/divetooltipitem.cpp | 4 ++-- 6 files changed, 7 insertions(+), 12 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index eb56d2e03..5fde4c45f 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -199,9 +199,8 @@ void DiveListView::unselectDives() QList DiveListView::selectedTrips() { - QModelIndexList indexes = selectionModel()->selectedRows(); QList ret; - Q_FOREACH (const QModelIndex &index, indexes) { + Q_FOREACH (const QModelIndex &index, selectionModel()->selectedRows()) { dive_trip_t *trip = static_cast(index.data(DiveTripModel::TRIP_ROLE).value()); if (!trip) continue; diff --git a/qt-ui/divepicturewidget.cpp b/qt-ui/divepicturewidget.cpp index 46e87d4f3..fd64f613a 100644 --- a/qt-ui/divepicturewidget.cpp +++ b/qt-ui/divepicturewidget.cpp @@ -52,8 +52,7 @@ void DivePictureModel::updateDivePictures() pictures.push_back(QString(picture->filename)); } - SPixmapList retList = QtConcurrent::blockingMapped(pictures, scaleImages); - Q_FOREACH (const SPixmap &pixmap, retList) + Q_FOREACH (const SPixmap &pixmap, QtConcurrent::blockingMapped(pictures, scaleImages)) stringPixmapCache[pixmap.first].image = pixmap.second; beginInsertRows(QModelIndex(), 0, numberOfPictures - 1); diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index a7950c074..050cf32f6 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -80,8 +80,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui.timeEdit->installEventFilter(this); ui.tagWidget->installEventFilter(this); - QList statisticsTabWidgets = ui.statisticsTab->children(); - Q_FOREACH (QObject *obj, statisticsTabWidgets) { + Q_FOREACH (QObject *obj, ui.statisticsTab->children()) { QLabel *label = qobject_cast(obj); if (label) label->setAlignment(Qt::AlignHCenter); diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index ca6f6375f..a0bb97aa7 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -2035,8 +2035,7 @@ LanguageModel::LanguageModel(QObject *parent) : QAbstractListModel(parent) { QSettings s; QDir d(getSubsurfaceDataPath("translations")); - QStringList result = d.entryList(); - Q_FOREACH (const QString &s, result) { + Q_FOREACH (const QString &s, d.entryList()) { if (s.startsWith("subsurface_") && s.endsWith(".qm")) { languages.push_back((s == "subsurface_source.qm") ? "English" : s); } diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index cb24ec33a..a35675690 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -399,8 +399,7 @@ void PreferencesDialog::on_resetSettings_clicked() if (result == QMessageBox::Ok) { prefs = default_prefs; setUiFromPrefs(); - QStringList keys = s.allKeys(); - Q_FOREACH (QString key, keys) { + Q_FOREACH (QString key, s.allKeys()) { s.remove(key); } syncSettings(); diff --git a/qt-ui/profile/divetooltipitem.cpp b/qt-ui/profile/divetooltipitem.cpp index 032daf6ee..40c556cc6 100644 --- a/qt-ui/profile/divetooltipitem.cpp +++ b/qt-ui/profile/divetooltipitem.cpp @@ -229,8 +229,8 @@ void ToolTipItem::refresh(const QPointF &pos) addToolTip(QString::fromUtf8(mb.buffer, mb.len)); free_buffer(&mb); - QList items = scene()->items(pos, Qt::IntersectsItemShape, Qt::DescendingOrder, scene()->views().first()->transform()); - Q_FOREACH (QGraphicsItem *item, items) { + Q_FOREACH (QGraphicsItem *item, scene()->items(pos, Qt::IntersectsItemShape + ,Qt::DescendingOrder, scene()->views().first()->transform())) { if (!item->toolTip().isEmpty()) addToolTip(item->toolTip()); } -- cgit v1.2.3-70-g09d2