Changeset 10747


Ignore:
Timestamp:
Jun 13, 2010, 11:06:50 PM (13 years ago)
Author:
charles
Message:

(trunk libT) small speed improvements to comparePeerCandidates()

File:
1 edited

Legend:

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

    r10746 r10747  
    32723272struct peer_candidate
    32733273{
     3274    int from;
    32743275    int salt;
     3276    int priority;
     3277    int seedProbability;
     3278    int wasRecentlyStarted;
     3279    time_t lastConnectionAt;
     3280    time_t lastConnectionAttemptAt;
    32753281    tr_torrent * tor;
    32763282    struct peer_atom * atom;
    3277     tr_priority_t priority;
    3278     tr_bool wasRecentlyStarted;
     3283   
    32793284};
    32803285
     
    33103315
    33113316    /* prefer peers we've connected to, or never tried, over peers we failed to connect to. */
    3312     af = a->atom->lastConnectionAt < a->atom->lastConnectionAttemptAt;
    3313     bf = b->atom->lastConnectionAt < b->atom->lastConnectionAttemptAt;
     3317    af = a->lastConnectionAt < a->lastConnectionAttemptAt;
     3318    bf = b->lastConnectionAt < b->lastConnectionAttemptAt;
    33143319    if( af != bf )
    33153320        return af ? 1 : -1;
    33163321
    33173322    /* prefer the one we attempted least recently (to cycle through all peers) */
    3318     if( a->atom->lastConnectionAttemptAt != b->atom->lastConnectionAttemptAt )
    3319         return a->atom->lastConnectionAttemptAt < b->atom->lastConnectionAttemptAt ? -1 : 1;
     3323    if( a->lastConnectionAttemptAt != b->lastConnectionAttemptAt )
     3324        return a->lastConnectionAttemptAt < b->lastConnectionAttemptAt ? -1 : 1;
    33203325
    33213326    /* prefer peers belonging to a torrent of a higher priority */
     
    33283333
    33293334    /* prefer peers that we might have a chance of uploading to */
    3330     if(( i = compareSeedProbabilities( a->atom->seedProbability, b->atom->seedProbability )))
     3335    if(( i = compareSeedProbabilities( a->seedProbability, b->seedProbability )))
    33313336        return i;
    33323337
    33333338    /* prefer peers that we got from more trusted sources */
    3334     if( a->atom->from != b->atom->from )
    3335         return a->atom->from < b->atom->from ? -1 : 1;
     3339    if( a->from != b->from )
     3340        return a->from < b->from ? -1 : 1;
    33363341
    33373342    /* salt */
     
    33963401                walk->tor = tor;
    33973402                walk->atom = atom;
     3403                walk->from = atom->from;
    33983404                walk->salt = tr_cryptoWeakRandInt( 4096 );
    33993405                walk->priority = tr_torrentGetPriority( tor );
     3406                walk->seedProbability = atom->seedProbability;
    34003407                walk->wasRecentlyStarted = torrentWasRecentlyStarted( tor );
     3408                walk->lastConnectionAt = atom->lastConnectionAt;
     3409                walk->lastConnectionAttemptAt = atom->lastConnectionAttemptAt;
    34013410                ++walk;
    34023411            }
Note: See TracChangeset for help on using the changeset viewer.