Ignore:
Timestamp:
May 16, 2009, 5:51:52 AM (13 years ago)
Author:
charles
Message:

(trunk) add an option to the JSON generator to disable the human-readable indentations. Keep indenting the data files such as settings.json, but don't indent the messages used for RPC. This cuts the cost of deflate()ing those RPC messages by about 80%...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r8413 r8414  
    10651065        else
    10661066        {
    1067             const tr_block_index_t firstBlockOfLastPiece = tr_torPieceFirstBlock( tor, f->lastPiece );
    1068             const tr_block_index_t lastBlockOfFirstPiece = tr_torPieceFirstBlock( tor, f->firstPiece )
    1069                                                          + tr_torPieceCountBlocks( tor, f->firstPiece )
    1070                                                          - 1;
     1067            int64_t b = 0;
     1068            const tr_block_index_t firstBlockOfLastPiece
     1069                       = tr_torPieceFirstBlock( tor, f->lastPiece );
     1070            const tr_block_index_t lastBlockOfFirstPiece
     1071                       = tr_torPieceFirstBlock( tor, f->firstPiece )
     1072                         + tr_torPieceCountBlocks( tor, f->firstPiece ) - 1;
     1073
    10711074            /* the rest of the first piece */
    10721075            for( i=firstBlock+1; i<lastBlock && i<=lastBlockOfFirstPiece; ++i )
    10731076                if( tr_cpBlockIsCompleteFast( &tor->completion, i ) )
    1074                     total += tor->blockSize;
     1077                    ++b;
    10751078
    10761079            /* the middle pieces */
    1077             if( f->firstPiece + 1 < f->lastPiece ) {
    1078                 uint64_t b = tor->blockCountInPiece * ( f->lastPiece - ( f->firstPiece + 1 ) );
     1080            if( f->firstPiece + 1 < f->lastPiece )
    10791081                for( i=f->firstPiece+1; i<f->lastPiece; ++i )
    1080                     b -= tr_cpMissingBlocksInPiece( &tor->completion, i );
    1081                 b *= tor->blockSize;
    1082                 total += b;
    1083             }
     1082                    b += tor->blockCountInPiece - tr_cpMissingBlocksInPiece( &tor->completion, i );
    10841083
    10851084            /* the rest of the last piece */
    10861085            for( i=firstBlockOfLastPiece; i<lastBlock; ++i )
    10871086                if( tr_cpBlockIsCompleteFast( &tor->completion, i ) )
    1088                     total += tor->blockSize;
     1087                    ++b;
     1088
     1089            b *= tor->blockSize;
     1090            total += b;
    10891091        }
    10901092
Note: See TracChangeset for help on using the changeset viewer.