Changeset 6622


Ignore:
Timestamp:
Aug 22, 2008, 2:15:37 AM (13 years ago)
Author:
muks
Message:

Further fix/cleanup compare code

File:
1 edited

Legend:

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

    r6621 r6622  
    185185compareAddresses( const struct in_addr * a, const struct in_addr * b )
    186186{
    187     return tr_compareUint32( a->s_addr, b->s_addr );
     187    if (a->s_addr != b->s_addr)
     188        return a->s_addr < b->s_addr ? -1 : 1;
     189
     190    return 0;
    188191}
    189192
     
    565568    if( a->priority != b->priority )
    566569        return a->priority > b->priority ? -1 : 1;
    567    
     570
    568571    /* otherwise if one has fewer peers, it goes first */
    569572    if (a->peerCount != b->peerCount)
     
    571574
    572575    /* otherwise go with our random seed */
    573     return a->random - b->random;
     576    if (a->random != b->random)
     577        return a->random < b->random ? -1 : 1;
     578
     579    return 0;
    574580}
    575581
     
    17721778    const struct peer_atom * b = * (const struct peer_atom**) vb;
    17731779
    1774     if( a->piece_data_time > b->piece_data_time ) return -1;
    1775     if( a->piece_data_time < b->piece_data_time ) return 1;
     1780    if( a->piece_data_time != b->piece_data_time )
     1781        return a->piece_data_time < b->piece_data_time ? -1 : 1;
    17761782
    17771783    if( a->numFails != b->numFails )
Note: See TracChangeset for help on using the changeset viewer.