In TorrentModel.updateTorrents(), don't call getIds() if we don't need them

This commit is contained in:
Jordan Lee 2012-12-29 21:05:05 +00:00
parent 93da75c842
commit 162ccc6d3a
2 changed files with 13 additions and 7 deletions

View File

@ -138,11 +138,14 @@ void
TorrentModel :: updateTorrents( tr_variant * torrents, bool isCompleteList )
{
QList<Torrent*> newTorrents;
QSet<int> oldIds( getIds( ) );
QSet<int> oldIds;
QSet<int> addIds;
QSet<int> newIds;
int updatedCount = 0;
if ( isCompleteList )
oldIds = getIds( );
if( tr_variantIsList( torrents ) )
{
size_t i( 0 );
@ -246,12 +249,15 @@ TorrentModel :: getDownloadSpeed( ) const
}
QSet<int>
TorrentModel :: getIds( ) const
TorrentModel :: getIds () const
{
QSet<int> ids;
foreach( const Torrent * tor, myTorrents )
ids.insert( tor->id( ) );
return ids;
QSet<int> ids;
ids.reserve (myTorrents.size());
foreach (const Torrent * tor, myTorrents)
ids.insert (tor->id());
return ids;
}
bool

View File

@ -51,10 +51,10 @@ class TorrentModel: public QAbstractListModel
public:
Torrent* getTorrentFromId( int id );
const Torrent* getTorrentFromId( int id ) const;
QSet<int> getIds( ) const;
private:
void addTorrent( Torrent * );
QSet<int> getIds( ) const;
public:
Speed getUploadSpeed( ) const;