Changeset 13718


Ignore:
Timestamp:
Dec 29, 2012, 9:05:05 PM (8 years ago)
Author:
jordan
Message:

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

Location:
trunk/qt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/torrent-model.cc

    r13713 r13718  
    139139{
    140140    QList<Torrent*> newTorrents;
    141     QSet<int> oldIds( getIds( ) );
     141    QSet<int> oldIds;
    142142    QSet<int> addIds;
    143143    QSet<int> newIds;
    144144    int updatedCount = 0;
     145
     146    if ( isCompleteList )
     147      oldIds = getIds( );
    145148
    146149    if( tr_variantIsList( torrents ) )
     
    247250
    248251QSet<int>
    249 TorrentModel :: getIds( ) const
    250 {
    251     QSet<int> ids;
    252     foreach( const Torrent * tor, myTorrents )
    253         ids.insert( tor->id( ) );
    254     return ids;
     252TorrentModel :: getIds () const
     253{
     254  QSet<int> ids;
     255
     256  ids.reserve (myTorrents.size());
     257  foreach (const Torrent * tor, myTorrents)
     258    ids.insert (tor->id());
     259
     260  return ids;
    255261}
    256262
  • trunk/qt/torrent-model.h

    r13667 r13718  
    5252        Torrent* getTorrentFromId( int id );
    5353        const Torrent* getTorrentFromId( int id ) const;
    54         QSet<int> getIds( ) const;
    5554
    5655    private:
    5756        void addTorrent( Torrent * );
     57        QSet<int> getIds( ) const;
    5858
    5959    public:
Note: See TracChangeset for help on using the changeset viewer.