Skip to content

Commit

Permalink
Prevent temporary copies of QList
Browse files Browse the repository at this point in the history
  • Loading branch information
uklotzde committed Dec 11, 2019
1 parent 98ce67d commit d1e0d1e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/library/dao/playlistdao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ void PlaylistDAO::removeTracksFromPlaylist(int playlistId, QList<int> 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();
Expand Down
2 changes: 1 addition & 1 deletion src/library/playlistfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ void PlaylistFeature::slotPlaylistContentChanged(QSet<int> 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
Expand Down
4 changes: 3 additions & 1 deletion src/library/playlisttablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/library/setlogfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ void SetlogFeature::slotPlaylistContentChanged(QSet<int> 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
Expand Down

0 comments on commit d1e0d1e

Please sign in to comment.