Ignore:
Timestamp:
Mar 29, 2011, 1:17:18 AM (11 years ago)
Author:
jordan
Message:

(trunk libT) more completion and bitfield cleanup: (1) fix regression in tr_cpSizeWhenDone() reported by Waldorf, (2) make simple one-liner functions inlined

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/completion.h

    r12248 r12251  
    2626    tr_torrent * tor;
    2727
    28     /* do we have this block? */
    2928    tr_bitfield blockBitfield;
    3029
     
    5453**/
    5554
    56 void              tr_cpConstruct( tr_completion *, tr_torrent * );
     55void  tr_cpConstruct( tr_completion *, tr_torrent * );
    5756
    58 void              tr_cpDestruct( tr_completion * );
     57bool  tr_cpBlockInit( tr_completion * cp, const tr_bitfield * blocks );
     58
     59static inline void
     60tr_cpDestruct( tr_completion * cp )
     61{
     62    tr_bitfieldDestruct( &cp->blockBitfield );
     63}
    5964
    6065/**
     
    7277uint64_t          tr_cpSizeWhenDone( const tr_completion * );
    7378
    74 uint64_t          tr_cpLeftUntilComplete( const tr_completion * );
    75 
    76 uint64_t          tr_cpLeftUntilDone( const tr_completion * );
    77 
    7879void              tr_cpGetAmountDone( const   tr_completion * completion,
    7980                                      float                 * tab,
    8081                                      int                     tabCount );
     82
     83
     84static inline uint64_t
     85tr_cpHaveTotal( const tr_completion * cp )
     86{
     87    return cp->sizeNow;
     88}
     89
     90static inline uint64_t
     91tr_cpLeftUntilComplete( const tr_completion * cp )
     92{
     93    return tr_torrentInfo(cp->tor)->totalSize - cp->sizeNow;
     94}
     95
     96static inline uint64_t
     97tr_cpLeftUntilDone( const tr_completion * cp )
     98{
     99    return tr_cpSizeWhenDone( cp ) - cp->sizeNow;
     100}
    81101
    82102static inline bool tr_cpHasAll( const tr_completion * cp )
     
    88108{
    89109    return tr_bitfieldHasNone( &cp->blockBitfield );
    90 }
    91 
    92 static inline uint64_t tr_cpHaveTotal( const tr_completion * cp )
    93 {
    94     return cp->sizeNow;
    95110}
    96111
     
    117132**/
    118133
     134void  tr_cpBlockAdd( tr_completion * cp, tr_block_index_t i );
     135
    119136static inline bool
    120137tr_cpBlockIsComplete( const tr_completion * cp, tr_block_index_t i )
     
    122139    return tr_bitfieldHas( &cp->blockBitfield, i );
    123140}
    124 
    125 void  tr_cpBlockAdd( tr_completion * cp, tr_block_index_t i );
    126 
    127 bool  tr_cpBlockInit( tr_completion * cp, const tr_bitfield * blocks );
    128141
    129142/***
     
    133146bool  tr_cpFileIsComplete( const tr_completion * cp, tr_file_index_t );
    134147
    135 void  tr_cpInvalidateDND( tr_completion * );
     148void* tr_cpCreatePieceBitfield( const tr_completion * cp, size_t * byte_count );
    136149
    137 void* tr_cpCreatePieceBitfield( const tr_completion * cp, size_t * byte_count );
     150static inline void
     151tr_cpInvalidateDND( tr_completion * cp )
     152{
     153    cp->sizeWhenDoneIsDirty = true;
     154}
    138155
    139156
Note: See TracChangeset for help on using the changeset viewer.