Changeset 12263


Ignore:
Timestamp:
Mar 30, 2011, 4:23:20 AM (11 years ago)
Author:
jordan
Message:

(trunk libT) merge tr_bitfieldTestFast() and tr_bitfieldTest()

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bitfield.h

    r12262 r12263  
    9898}
    9999
    100 /** A stripped-down version of bitfieldHas to be used
    101     for speed when you're looping quickly. This version
    102     has none of tr_bitfieldHas()'s safety checks, so you
    103     need to call tr_bitfieldTestFast() first before you
    104     start looping. */
    105 static inline bool
    106 tr_bitfieldHasFast( const tr_bitfield * b, const size_t n )
    107 {
    108     if( tr_bitfieldHasAll( b ) ) return true;
    109     if( tr_bitfieldHasNone( b ) ) return false;
    110     return ( b->bits[n>>3u] << ( n & 7u ) & 0x80 ) != 0;
    111 }
    112 
    113 /** @param high the highest nth bit you're going to access */
    114 static inline bool
    115 tr_bitfieldTestFast( const tr_bitfield * b, const size_t high )
    116 {
    117     return ( b != NULL )
    118         && ( high < b->bit_count );
    119 }
    120 
    121100static inline bool
    122101tr_bitfieldHas( const tr_bitfield * b, size_t n )
  • trunk/libtransmission/peer-mgr.c

    r12258 r12263  
    12451245
    12461246    assert( replicationExists( t ) );
    1247     assert( n == t->pieceReplicationSize );
    1248     assert( tr_bitfieldTestFast( b, n-1 ) );
    12491247
    12501248    for( i=0; i<n; ++i )
  • trunk/libtransmission/session.c

    r12248 r12263  
    13361336        minute_of_the_week = MINUTES_PER_WEEK - 1;
    13371337
    1338     e = tr_bitfieldHasFast( &t->minutes, minute_of_the_week );
     1338    e = tr_bitfieldHas( &t->minutes, minute_of_the_week );
    13391339    if( enabled != NULL )
    13401340        *enabled = e;
     
    13441344        const size_t prev = minute_of_the_week > 0 ? minute_of_the_week - 1
    13451345                                                   : MINUTES_PER_WEEK - 1;
    1346         *changed = e != tr_bitfieldHasFast( &t->minutes, prev );
     1346        *changed = e != tr_bitfieldHas( &t->minutes, prev );
    13471347    }
    13481348}
Note: See TracChangeset for help on using the changeset viewer.