Changeset 10744


Ignore:
Timestamp:
Jun 13, 2010, 5:17:33 PM (12 years ago)
Author:
charles
Message:

(trunk libT) speedups to comparePeerCandidates()

File:
1 edited

Legend:

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

    r10725 r10744  
    32753275    tr_torrent * tor;
    32763276    struct peer_atom * atom;
     3277    tr_priority_t priority;
     3278    tr_bool wasRecentlyStarted;
    32773279};
    32783280
     
    33003302comparePeerCandidates( const void * va, const void * vb )
    33013303{
    3302     int i, ai, bi;
     3304    int i;
    33033305    tr_bool af, bf;
    33043306    const struct peer_candidate * a = va;
     
    33163318
    33173319    /* prefer peers belonging to a torrent of a higher priority */
    3318     ai = tr_torrentGetPriority( a->tor );
    3319     bi = tr_torrentGetPriority( b->tor );
    3320     if( ai != bi )
    3321         return ai > bi ? -1 : 1;
     3320    if( a->priority != b->priority )
     3321        return a->priority > b->priority ? -1 : 1;
    33223322
    33233323    /* prefer recently-started torrents */
    3324     af = torrentWasRecentlyStarted( a->tor );
    3325     bf = torrentWasRecentlyStarted( a->tor );
    3326     if( af != bf )
    3327         return af ? -1 : 1;
     3324    if( a->wasRecentlyStarted != b->wasRecentlyStarted )
     3325        return a->wasRecentlyStarted ? -1 : 1;
    33283326
    33293327    /* prefer peers that we might have a chance of uploading to */
     
    33973395                walk->atom = atom;
    33983396                walk->salt = tr_cryptoWeakRandInt( 4096 );
     3397                walk->priority = tr_torrentGetPriority( tor );
     3398                walk->wasRecentlyStarted = torrentWasRecentlyStarted( tor );
    33993399                ++walk;
    34003400            }
Note: See TracChangeset for help on using the changeset viewer.