Ignore:
Timestamp:
Jan 2, 2009, 6:28:22 AM (13 years ago)
Author:
charles
Message:

(trunk libT) add "inline" hint to several one-liner functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.h

    r7525 r7576  
    6464                                   tr_bool          has );
    6565
    66 void        tr_torrentLock( const tr_torrent * session );
    67 
    68 void        tr_torrentUnlock( const tr_torrent * session );
     66extern inline void
     67            tr_torrentLock( const tr_torrent * session );
     68
     69extern inline void
     70            tr_torrentUnlock( const tr_torrent * session );
    6971
    7072tr_bool     tr_torrentIsSeed( const tr_torrent * session );
     
    7274void        tr_torrentChangeMyPort( tr_torrent * session );
    7375
    74 tr_bool     tr_torrentExists( const tr_session * session,
     76extern inline tr_bool
     77            tr_torrentExists( const tr_session * session,
    7578                              const uint8_t    * hash );
    7679
     
    9295                                              tr_direction       direction );
    9396
    94 /* get the index of this piece's first block */
    95 #define tr_torPieceFirstBlock( tor, piece ) ( ( piece ) *\
    96                                              ( tor )->blockCountInPiece )
    97 
    98 /* what piece index is this block in? */
    99 #define tr_torBlockPiece( tor, block ) ( ( block ) /\
    100                                         ( tor )->blockCountInPiece )
    101 
    102 /* how many blocks are in this piece? */
    103 #define tr_torPieceCountBlocks( tor, piece ) \
    104     ( ( ( piece ) ==\
    105        ( ( tor )->info.pieceCount - \
    106         1 ) ) ? ( tor )->blockCountInLastPiece : ( tor )->blockCountInPiece )
    107 
    108 /* how many bytes are in this piece? */
    109 #define tr_torPieceCountBytes( tor, piece ) \
    110     ( ( ( piece ) ==\
    111        ( ( tor )->info.pieceCount - \
    112         1 ) ) ? ( tor )->lastPieceSize : ( tor )->info.pieceSize )
    113 
    114 /* how many bytes are in this block? */
    115 #define tr_torBlockCountBytes( tor, block ) \
    116     ( ( ( block ) ==\
    117        ( ( tor )->blockCount - \
    118         1 ) ) ? ( tor )->lastBlockSize : ( tor )->blockSize )
    11997
    12098#define tr_block( a, b ) _tr_block( tor, a, b )
     
    246224};
    247225
     226/* get the index of this piece's first block */
     227static inline tr_block_index_t
     228tr_torPieceFirstBlock( const tr_torrent * tor, const tr_piece_index_t piece )
     229{
     230    return piece * tor->blockCountInPiece;
     231}
     232
     233/* what piece index is this block in? */
     234static inline tr_piece_index_t
     235tr_torBlockPiece( const tr_torrent * tor, const tr_block_index_t block )
     236{
     237    return block / tor->blockCountInPiece;
     238}
     239
     240/* how many blocks are in this piece? */
     241static inline uint32_t
     242tr_torPieceCountBlocks( const tr_torrent * tor, const tr_piece_index_t piece )
     243{
     244    return piece == tor->info.pieceCount - 1 ? tor->blockCountInLastPiece
     245                                             : tor->blockCountInPiece;
     246}
     247
     248/* how many bytes are in this piece? */
     249static inline uint32_t
     250tr_torPieceCountBytes( const tr_torrent * tor, const tr_piece_index_t piece )
     251{
     252    return piece == tor->info.pieceCount - 1 ? tor->lastPieceSize
     253                                             : tor->info.pieceSize;
     254}
     255
     256/* how many bytes are in this block? */
     257static inline uint32_t
     258tr_torBlockCountBytes( const tr_torrent * tor, const tr_block_index_t block )
     259{
     260    return block == tor->blockCount - 1 ? tor->lastBlockSize
     261                                        : tor->blockSize;
     262}
     263
    248264#endif
Note: See TracChangeset for help on using the changeset viewer.