Changeset 10750


Ignore:
Timestamp:
Jun 14, 2010, 11:57:46 AM (12 years ago)
Author:
charles
Message:

(trunk libT) when filtering out peers that aren't candidates, use the fastest filter tests first, so that the more expensive tests will be applied to fewer peers. In particular, call peerIsInUse() last.

File:
1 edited

Legend:

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

    r10749 r10750  
    272272}
    273273
    274 static tr_handshake*
    275 getExistingHandshake( tr_ptrArray      * handshakes,
    276                       const tr_address * addr )
    277 {
     274static inline tr_handshake*
     275getExistingHandshake( tr_ptrArray * handshakes, const tr_address * addr )
     276{
     277    if( tr_ptrArrayEmpty( handshakes ) )
     278        return NULL;
     279
    278280    return tr_ptrArrayFindSorted( handshakes, addr, handshakeCompareToAddr );
    279281}
     
    567569}
    568570
    569 static tr_bool
     571static inline tr_bool
    570572atomIsSeed( const struct peer_atom * atom )
    571573{
     
    32453247isPeerCandidate( const tr_torrent * tor, const struct peer_atom * atom, const time_t now )
    32463248{
    3247     /* not if we've already got a connection to them... */
    3248     if( peerIsInUse( tor->torrentPeers, atom ) )
    3249         return FALSE;
    3250 
    32513249    /* not if they're banned... */
    32523250    if( atom->myflags & MYFLAG_BANNED )
     
    32673265        return FALSE;
    32683266
     3267    /* not if we've already got a connection to them...  */
     3268    if( peerIsInUse( tor->torrentPeers, atom ) )
     3269        return FALSE;
     3270
    32693271    return TRUE;
    32703272}
     
    33433345    const struct peer_candidate * b = vb;
    33443346
    3345     if( a->score != b->score )
    3346         return a->score < b->score ? -1 : 1;
     3347    if( a->score < b->score ) return -1;
     3348    if( a->score > b->score ) return 1;
    33473349
    33483350    return 0;
Note: See TracChangeset for help on using the changeset viewer.