diff --git a/qt/torrent-model.cc b/qt/torrent-model.cc index 2f5e0dcea..af74f64c7 100644 --- a/qt/torrent-model.cc +++ b/qt/torrent-model.cc @@ -138,11 +138,14 @@ void TorrentModel :: updateTorrents( tr_variant * torrents, bool isCompleteList ) { QList newTorrents; - QSet oldIds( getIds( ) ); + QSet oldIds; QSet addIds; QSet newIds; int updatedCount = 0; + if ( isCompleteList ) + oldIds = getIds( ); + if( tr_variantIsList( torrents ) ) { size_t i( 0 ); @@ -246,12 +249,15 @@ TorrentModel :: getDownloadSpeed( ) const } QSet -TorrentModel :: getIds( ) const +TorrentModel :: getIds () const { - QSet ids; - foreach( const Torrent * tor, myTorrents ) - ids.insert( tor->id( ) ); - return ids; + QSet ids; + + ids.reserve (myTorrents.size()); + foreach (const Torrent * tor, myTorrents) + ids.insert (tor->id()); + + return ids; } bool diff --git a/qt/torrent-model.h b/qt/torrent-model.h index d33d65385..5e512e9db 100644 --- a/qt/torrent-model.h +++ b/qt/torrent-model.h @@ -51,10 +51,10 @@ class TorrentModel: public QAbstractListModel public: Torrent* getTorrentFromId( int id ); const Torrent* getTorrentFromId( int id ) const; - QSet getIds( ) const; private: void addTorrent( Torrent * ); + QSet getIds( ) const; public: Speed getUploadSpeed( ) const;