Changeset 7027


Ignore:
Timestamp:
Nov 3, 2008, 5:01:08 PM (12 years ago)
Author:
charles
Message:

(libT) micro-optimizations suggested by cachegrind

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/completion.c

    r6935 r7027  
    304304tr_cpHaveValid( const tr_completion * cp )
    305305{
    306     uint64_t           b = 0;
    307     tr_piece_index_t   i;
    308     const tr_torrent * tor = cp->tor;
    309 
    310     for( i = 0; i < tor->info.pieceCount; ++i )
     306    uint64_t                  b = 0;
     307    tr_piece_index_t          i;
     308    const tr_torrent        * tor            = cp->tor;
     309    const uint64_t            pieceSize      = tor->info.pieceSize;
     310    const uint64_t            lastPieceSize  = tor->lastPieceSize;
     311    const tr_piece_index_t    lastPiece      = tor->info.pieceCount - 1;
     312
     313    for( i=0; i!=lastPiece; ++i )
    311314        if( tr_cpPieceIsComplete( cp, i ) )
    312             b += tr_torPieceCountBytes( tor, i );
     315            b += pieceSize;
     316
     317    if( tr_cpPieceIsComplete( cp, lastPiece ) )
     318        b += lastPieceSize;
    313319
    314320    return b;
  • trunk/libtransmission/torrent.c

    r6975 r7027  
    100100
    101101    while( ( tor = tr_torrentNext( handle, tor ) ) )
    102         if( !memcmp( tor->info.hash, torrentHash, SHA_DIGEST_LENGTH ) )
    103             return tor;
     102        if( *tor->info.hash == *torrentHash )
     103            if( !memcmp( tor->info.hash, torrentHash, SHA_DIGEST_LENGTH ) )
     104                return tor;
    104105
    105106    return NULL;
Note: See TracChangeset for help on using the changeset viewer.