From d1e0d1e97b02ee77b924f60d8c439d3ead5c18d8 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Thu, 12 Dec 2019 00:05:44 +0100 Subject: [PATCH] Prevent temporary copies of QList --- src/library/dao/playlistdao.cpp | 2 +- src/library/playlistfeature.cpp | 2 +- src/library/playlisttablemodel.cpp | 4 +++- src/library/setlogfeature.cpp | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/library/dao/playlistdao.cpp b/src/library/dao/playlistdao.cpp index 2734cc82b65..c81a702ffa2 100644 --- a/src/library/dao/playlistdao.cpp +++ b/src/library/dao/playlistdao.cpp @@ -458,7 +458,7 @@ void PlaylistDAO::removeTracksFromPlaylist(int playlistId, QList positions) //qDebug() << "PlaylistDAO::removeTrackFromPlaylist" // << QThread::currentThread() << m_database.connectionName(); ScopedTransaction transaction(m_database); - for (const auto position : positions) { + for (const auto position : qAsConst(positions)) { removeTracksFromPlaylistInner(playlistId, position); } transaction.commit(); diff --git a/src/library/playlistfeature.cpp b/src/library/playlistfeature.cpp index c199cd670b4..f87e42e797d 100644 --- a/src/library/playlistfeature.cpp +++ b/src/library/playlistfeature.cpp @@ -237,7 +237,7 @@ void PlaylistFeature::slotPlaylistContentChanged(QSet playlistIds) { return; } - for (const auto playlistId : playlistIds) { + for (const auto playlistId : qAsConst(playlistIds)) { enum PlaylistDAO::HiddenType type = m_playlistDao.getHiddenType(playlistId); if (type == PlaylistDAO::PLHT_NOT_HIDDEN || type == PlaylistDAO::PLHT_UNKNOWN) { // In case of a deleted Playlist diff --git a/src/library/playlisttablemodel.cpp b/src/library/playlisttablemodel.cpp index fc71087da51..06a77138932 100644 --- a/src/library/playlisttablemodel.cpp +++ b/src/library/playlisttablemodel.cpp @@ -132,7 +132,9 @@ void PlaylistTableModel::removeTracks(const QModelIndexList& indices) { trackPositions.append(trackPosition); } - m_pTrackCollection->getPlaylistDAO().removeTracksFromPlaylist(m_iPlaylistId, trackPositions); + m_pTrackCollection->getPlaylistDAO().removeTracksFromPlaylist( + m_iPlaylistId, + std::move(trackPositions)); } void PlaylistTableModel::moveTrack(const QModelIndex& sourceIndex, diff --git a/src/library/setlogfeature.cpp b/src/library/setlogfeature.cpp index 5ccddcca3d1..c6bc6c98c40 100644 --- a/src/library/setlogfeature.cpp +++ b/src/library/setlogfeature.cpp @@ -337,7 +337,7 @@ void SetlogFeature::slotPlaylistContentChanged(QSet playlistIds) { return; } - for (const auto playlistId : playlistIds) { + for (const auto playlistId : qAsConst(playlistIds)) { enum PlaylistDAO::HiddenType type = m_playlistDao.getHiddenType(playlistId); if (type == PlaylistDAO::PLHT_SET_LOG || type == PlaylistDAO::PLHT_UNKNOWN) { // In case of a deleted Playlist