mirror of
https://github.com/transmission/transmission
synced 2025-03-10 14:13:23 +00:00
(trunk libT) merge tr_bitfieldTestFast() and tr_bitfieldTest()
This commit is contained in:
parent
3660c44934
commit
210068410d
3 changed files with 2 additions and 25 deletions
|
@ -97,27 +97,6 @@ tr_bitfieldHasNone( const tr_bitfield * b )
|
|||
return b->bit_count ? ( b->true_count == 0 ) : b->have_none_hint;
|
||||
}
|
||||
|
||||
/** A stripped-down version of bitfieldHas to be used
|
||||
for speed when you're looping quickly. This version
|
||||
has none of tr_bitfieldHas()'s safety checks, so you
|
||||
need to call tr_bitfieldTestFast() first before you
|
||||
start looping. */
|
||||
static inline bool
|
||||
tr_bitfieldHasFast( const tr_bitfield * b, const size_t n )
|
||||
{
|
||||
if( tr_bitfieldHasAll( b ) ) return true;
|
||||
if( tr_bitfieldHasNone( b ) ) return false;
|
||||
return ( b->bits[n>>3u] << ( n & 7u ) & 0x80 ) != 0;
|
||||
}
|
||||
|
||||
/** @param high the highest nth bit you're going to access */
|
||||
static inline bool
|
||||
tr_bitfieldTestFast( const tr_bitfield * b, const size_t high )
|
||||
{
|
||||
return ( b != NULL )
|
||||
&& ( high < b->bit_count );
|
||||
}
|
||||
|
||||
static inline bool
|
||||
tr_bitfieldHas( const tr_bitfield * b, size_t n )
|
||||
{
|
||||
|
|
|
@ -1244,8 +1244,6 @@ tr_incrReplicationFromBitfield( Torrent * t, const tr_bitfield * b )
|
|||
const size_t n = t->tor->info.pieceCount;
|
||||
|
||||
assert( replicationExists( t ) );
|
||||
assert( n == t->pieceReplicationSize );
|
||||
assert( tr_bitfieldTestFast( b, n-1 ) );
|
||||
|
||||
for( i=0; i<n; ++i )
|
||||
if( tr_bitfieldHas( b, i ) )
|
||||
|
|
|
@ -1335,7 +1335,7 @@ testTurtleTime( const struct tr_turtle_info * t,
|
|||
if( minute_of_the_week >= MINUTES_PER_WEEK ) /* leap minutes? */
|
||||
minute_of_the_week = MINUTES_PER_WEEK - 1;
|
||||
|
||||
e = tr_bitfieldHasFast( &t->minutes, minute_of_the_week );
|
||||
e = tr_bitfieldHas( &t->minutes, minute_of_the_week );
|
||||
if( enabled != NULL )
|
||||
*enabled = e;
|
||||
|
||||
|
@ -1343,7 +1343,7 @@ testTurtleTime( const struct tr_turtle_info * t,
|
|||
{
|
||||
const size_t prev = minute_of_the_week > 0 ? minute_of_the_week - 1
|
||||
: MINUTES_PER_WEEK - 1;
|
||||
*changed = e != tr_bitfieldHasFast( &t->minutes, prev );
|
||||
*changed = e != tr_bitfieldHas( &t->minutes, prev );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue