Changeset 12424


Ignore:
Timestamp:
May 10, 2011, 4:46:44 AM (10 years ago)
Author:
jordan
Message:

(trunk libT) CPU improvement in torrent.c's torrentInit()

Add the new torrent to the session's torrent list by prepending it instead of appending it. That way we don't have to walk the list in order to add it. tr_session.torrentList is an unordered list, so there's no real difference between prepending and appending.

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-mgr.c

    r12423 r12424  
    28292829    const int peerCount = tr_ptrArraySize( &t->peers );
    28302830    const time_t now = tr_time( );
     2831
     2832    /* some cases where this function isn't necessary */
     2833    if( tr_torrentIsSeed( t->tor ) )
     2834        return;
     2835    if ( tr_torrentIsPieceTransferAllowed( t->tor, TR_PEER_TO_CLIENT ) )
     2836        return;
    28312837
    28322838    /* decide HOW MANY peers to be interested in */
     
    31543160        if( tor->isRunning ) {
    31553161            Torrent * t = tor->torrentPeers;
    3156             if( tr_ptrArrayEmpty( &t->peers ) )
    3157                 continue;
    3158             rechokeUploads( t, now );
    3159             if( !tr_torrentIsSeed( tor ) && tr_torrentIsPieceTransferAllowed( tor, TR_PEER_TO_CLIENT ) )
     3162            if( !tr_ptrArrayEmpty( &t->peers ) ) {
     3163                rechokeUploads( t, now );
    31603164                rechokeDownloads( t );
     3165            }
    31613166        }
    31623167    }
  • trunk/libtransmission/torrent.c

    r12397 r12424  
    869869    }
    870870
    871     {
    872         tr_torrent * it = NULL;
    873         tr_torrent * last = NULL;
    874         while( ( it = tr_torrentNext( session, it ) ) )
    875             last = it;
    876 
    877         if( !last )
    878             session->torrentList = tor;
    879         else
    880             last->next = tor;
    881         ++session->torrentCount;
    882     }
     871    /* add the torrent to tr_session.torrentList */
     872    tor->next = session->torrentList;
     873    session->torrentList = tor;
     874    ++session->torrentCount;
    883875
    884876    /* if we don't have a local .torrent file already, assume the torrent is new */
Note: See TracChangeset for help on using the changeset viewer.