From e51ad048461042abd0fb322ed296f11e79b64039 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 5 Apr 2015 01:27:56 +0200 Subject: [PATCH] Don't use the slower length/count methods when isEmpty does the job. --- src/libtomahawk/DownloadJob.cpp | 2 +- src/libtomahawk/Playlist.cpp | 2 +- src/libtomahawk/Source.cpp | 2 +- src/libtomahawk/database/DatabaseCommand_Resolve.cpp | 2 +- src/libtomahawk/database/DatabaseImpl.cpp | 2 +- src/libtomahawk/network/DbSyncConnection.cpp | 2 +- src/libtomahawk/network/Servent.cpp | 4 ++-- src/libtomahawk/playlist/ColumnView.cpp | 2 +- src/libtomahawk/playlist/GridView.cpp | 2 +- src/libtomahawk/playlist/TrackView.cpp | 2 +- src/libtomahawk/resolvers/JSResolverHelper.cpp | 2 +- src/libtomahawk/resolvers/ScriptCommandQueue.cpp | 4 ++-- src/libtomahawk/resolvers/ScriptCommand_AllAlbums.cpp | 2 +- src/libtomahawk/viewpages/SearchViewPage.cpp | 4 ++-- src/libtomahawk/widgets/Breadcrumb.cpp | 2 +- src/tomahawk/widgets/AccountsToolButton.cpp | 2 +- 16 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/libtomahawk/DownloadJob.cpp b/src/libtomahawk/DownloadJob.cpp index 3ca453fc2..6314d2b63 100644 --- a/src/libtomahawk/DownloadJob.cpp +++ b/src/libtomahawk/DownloadJob.cpp @@ -337,7 +337,7 @@ DownloadJob::onDownloadProgress( qint64 rcvd, qint64 total ) } QByteArray data = m_reply->readAll(); - if ( data.length() == 0 ) + if ( data.isEmpty() ) return; if ( m_file->write( data ) < 0 ) diff --git a/src/libtomahawk/Playlist.cpp b/src/libtomahawk/Playlist.cpp index 1683fddd6..06eb216a3 100644 --- a/src/libtomahawk/Playlist.cpp +++ b/src/libtomahawk/Playlist.cpp @@ -586,7 +586,7 @@ void Playlist::setPlaylistRevisionFinished() { Q_D( Playlist ); - if ( d->queuedSetPlaylistRevisionCmds.length() > 0 ) + if ( !d->queuedSetPlaylistRevisionCmds.isEmpty() ) { DatabaseCommand_SetPlaylistRevision* cmd = d->queuedSetPlaylistRevisionCmds.dequeue(); // Update oldrev to currentRevision so that optimistic locking works correctly. diff --git a/src/libtomahawk/Source.cpp b/src/libtomahawk/Source.cpp index ffb06eb9f..06fd159f7 100644 --- a/src/libtomahawk/Source.cpp +++ b/src/libtomahawk/Source.cpp @@ -398,7 +398,7 @@ Source::addCollection( const collection_ptr& c ) { Q_D( Source ); - //Q_ASSERT( m_collections.length() == 0 ); // only 1 source supported atm + //Q_ASSERT( m_collections.isEmpty() ); // only 1 source supported atm d->collections.append( c ); emit collectionAdded( c ); } diff --git a/src/libtomahawk/database/DatabaseCommand_Resolve.cpp b/src/libtomahawk/database/DatabaseCommand_Resolve.cpp index 80ccfd20f..f3db6500d 100644 --- a/src/libtomahawk/database/DatabaseCommand_Resolve.cpp +++ b/src/libtomahawk/database/DatabaseCommand_Resolve.cpp @@ -241,7 +241,7 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib ) "track.id = file_join.track AND " "file.id = file_join.file AND " "%1" ) - .arg( trksl.length() > 0 ? trksToken : QString( "0" ) ); + .arg( !trksl.isEmpty() ? trksToken : QString( "0" ) ); files_query.prepare( sql ); files_query.exec(); diff --git a/src/libtomahawk/database/DatabaseImpl.cpp b/src/libtomahawk/database/DatabaseImpl.cpp index 1ca1de283..eabd292f5 100644 --- a/src/libtomahawk/database/DatabaseImpl.cpp +++ b/src/libtomahawk/database/DatabaseImpl.cpp @@ -219,7 +219,7 @@ Tomahawk::DatabaseImpl::updateSchema( int oldVersion ) foreach ( const QString& sl, statements ) { QString s( sl.trimmed() ); - if ( s.length() == 0 ) + if ( s.isEmpty() ) continue; tLog() << "Executing:" << s; diff --git a/src/libtomahawk/network/DbSyncConnection.cpp b/src/libtomahawk/network/DbSyncConnection.cpp index 3efe88fa5..9c256ed9f 100644 --- a/src/libtomahawk/network/DbSyncConnection.cpp +++ b/src/libtomahawk/network/DbSyncConnection.cpp @@ -268,7 +268,7 @@ DBSyncConnection::sendOpsData( QString sinceguid, QString lastguid, QList< dbop_ ops.clear(); m_lastSentOp = lastguid; - if ( ops.length() == 0 ) + if ( ops.isEmpty() ) { tLog( LOGVERBOSE ) << "Sending ok" << m_source->id() << m_source->friendlyName(); sendMsg( Msg::factory( "ok", Msg::DBOP ) ); diff --git a/src/libtomahawk/network/Servent.cpp b/src/libtomahawk/network/Servent.cpp index 297ccb16b..a213bdd4e 100644 --- a/src/libtomahawk/network/Servent.cpp +++ b/src/libtomahawk/network/Servent.cpp @@ -423,7 +423,7 @@ Servent::getLocalSipInfos( const QString& nodeid, const QString& key ) info.setNodeId( nodeid ); sipInfos.append( info ); } - if ( d_func()->externalHostname.length() > 0) + if ( !d_func()->externalHostname.isEmpty() ) { SipInfo info = SipInfo(); info.setHost( d_func()->externalHostname ); @@ -1047,7 +1047,7 @@ Servent::reverseOfferRequest( ControlConnection* orig_conn, const QString& their bool Servent::visibleExternally() const { - return (!d_func()->externalHostname.isNull()) || (d_func()->externalAddresses.length() > 0); + return !d_func()->externalHostname.isNull() || !d_func()->externalAddresses.isEmpty(); } diff --git a/src/libtomahawk/playlist/ColumnView.cpp b/src/libtomahawk/playlist/ColumnView.cpp index 694f71255..b2c685ea9 100644 --- a/src/libtomahawk/playlist/ColumnView.cpp +++ b/src/libtomahawk/playlist/ColumnView.cpp @@ -328,7 +328,7 @@ ColumnView::startDrag( Qt::DropActions supportedActions ) } } - if ( indexes.count() == 0 ) + if ( indexes.isEmpty() ) return; tDebug( LOGVERBOSE ) << "Dragging" << indexes.count() << "indexes"; diff --git a/src/libtomahawk/playlist/GridView.cpp b/src/libtomahawk/playlist/GridView.cpp index d4aed30a6..e9b621b04 100644 --- a/src/libtomahawk/playlist/GridView.cpp +++ b/src/libtomahawk/playlist/GridView.cpp @@ -386,7 +386,7 @@ GridView::startDrag( Qt::DropActions supportedActions ) } } - if ( indexes.count() == 0 ) + if ( indexes.isEmpty() ) return; qDebug() << "Dragging" << indexes.count() << "indexes"; diff --git a/src/libtomahawk/playlist/TrackView.cpp b/src/libtomahawk/playlist/TrackView.cpp index e57752942..0e1088092 100644 --- a/src/libtomahawk/playlist/TrackView.cpp +++ b/src/libtomahawk/playlist/TrackView.cpp @@ -719,7 +719,7 @@ TrackView::startDrag( Qt::DropActions supportedActions ) } } - if ( indexes.count() == 0 ) + if ( indexes.isEmpty() ) return; tDebug() << "Dragging" << indexes.count() << "indexes"; diff --git a/src/libtomahawk/resolvers/JSResolverHelper.cpp b/src/libtomahawk/resolvers/JSResolverHelper.cpp index 0ca59583e..b37e2fea8 100644 --- a/src/libtomahawk/resolvers/JSResolverHelper.cpp +++ b/src/libtomahawk/resolvers/JSResolverHelper.cpp @@ -507,7 +507,7 @@ JSResolverHelper::addUrlResult( const QString& url, const QVariantMap& result ) m_pendingAlbum = album; connect( album.data(), SIGNAL( tracksAdded( QList, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ), SLOT( tracksAdded( QList, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ) ); - if ( album->tracks().count() > 0 ) + if ( !album->tracks().isEmpty() ) { emit m_resolver->informationFound( url, album.objectCast() ); } diff --git a/src/libtomahawk/resolvers/ScriptCommandQueue.cpp b/src/libtomahawk/resolvers/ScriptCommandQueue.cpp index 98e11227c..fb02a30c5 100644 --- a/src/libtomahawk/resolvers/ScriptCommandQueue.cpp +++ b/src/libtomahawk/resolvers/ScriptCommandQueue.cpp @@ -80,7 +80,7 @@ ScriptCommandQueue::onCommandDone() disconnect( m_timer, SIGNAL( timeout() ), this, SLOT( onTimeout() ) ); - if ( m_queue.count() > 0 ) + if ( !m_queue.isEmpty() ) nextCommand(); } @@ -102,6 +102,6 @@ ScriptCommandQueue::onTimeout() disconnect( m_timer, SIGNAL( timeout() ), this, SLOT( onTimeout() ) ); - if ( m_queue.count() > 0 ) + if ( !m_queue.isEmpty() ) nextCommand(); } diff --git a/src/libtomahawk/resolvers/ScriptCommand_AllAlbums.cpp b/src/libtomahawk/resolvers/ScriptCommand_AllAlbums.cpp index 0aaffef9b..d61577913 100644 --- a/src/libtomahawk/resolvers/ScriptCommand_AllAlbums.cpp +++ b/src/libtomahawk/resolvers/ScriptCommand_AllAlbums.cpp @@ -112,7 +112,7 @@ ScriptCommand_AllAlbums::onAlbumsJobDone(const QVariantMap& result) } QList< Tomahawk::artist_ptr > resultArtists; - if ( result["artists"].toList().length() > 0 ) + if ( !result["artists"].toList().isEmpty() ) { resultArtists = ScriptCommand_AllArtists::parseArtistVariantList( result[ "artists" ].toList() ); } diff --git a/src/libtomahawk/viewpages/SearchViewPage.cpp b/src/libtomahawk/viewpages/SearchViewPage.cpp index d1247eb53..4e8ee5e2a 100644 --- a/src/libtomahawk/viewpages/SearchViewPage.cpp +++ b/src/libtomahawk/viewpages/SearchViewPage.cpp @@ -439,7 +439,7 @@ SearchWidget::updateArtists() qSort( floats.begin(), floats.end() ); - while ( floats.count() > 0 ) + while ( !floats.isEmpty() ) { float f = floats.takeLast(); foreach ( const artist_ptr& a, artists ) @@ -469,7 +469,7 @@ SearchWidget::updateAlbums() qSort( floats.begin(), floats.end() ); - while ( floats.count() > 0 ) + while ( !floats.isEmpty() ) { float f = floats.takeLast(); foreach ( const album_ptr& a, albums ) diff --git a/src/libtomahawk/widgets/Breadcrumb.cpp b/src/libtomahawk/widgets/Breadcrumb.cpp index b0e585e9a..6e4663beb 100644 --- a/src/libtomahawk/widgets/Breadcrumb.cpp +++ b/src/libtomahawk/widgets/Breadcrumb.cpp @@ -125,7 +125,7 @@ Breadcrumb::updateButtons( const QModelIndex& updateFrom ) btn->show(); // Animate all buttons except the first - if ( m_buttons.count() > 0 && isVisible() ) + if ( !m_buttons.isEmpty() && isVisible() ) { QPropertyAnimation* animation = new QPropertyAnimation( btn, "pos" ); animation->setDuration( 300 ); diff --git a/src/tomahawk/widgets/AccountsToolButton.cpp b/src/tomahawk/widgets/AccountsToolButton.cpp index 46251ab9c..dcf29230a 100644 --- a/src/tomahawk/widgets/AccountsToolButton.cpp +++ b/src/tomahawk/widgets/AccountsToolButton.cpp @@ -257,7 +257,7 @@ QSize AccountsToolButton::sizeHint() const { QSize size = QToolButton::sizeHint(); - if ( m_factoryPixmaps.count() == 0 ) //no accounts enabled! + if ( m_factoryPixmaps.isEmpty() ) //no accounts enabled! return size; size.rwidth() *= m_factoryPixmaps.count();