From 8eecf37a54975609aa0914ab85b9d2431ce4ce72 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 10 Dec 2008 03:45:57 +0000 Subject: [PATCH] (trunk libT) #1580: increase the read buffer for the "verify local data" reader to make it a little faster --- libtransmission/inout.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libtransmission/inout.c b/libtransmission/inout.c index 83e26ad89..7a662b1e2 100644 --- a/libtransmission/inout.c +++ b/libtransmission/inout.c @@ -30,6 +30,12 @@ #include "torrent.h" #include "utils.h" +#ifdef TR_EMBEDDED + #define TR_HASH_BUFSIZE (16*1024) +#else + #define TR_HASH_BUFSIZE (64*1024) +#endif + /**** ***** Low-level IO functions ****/ @@ -215,11 +221,15 @@ recalculateHash( const tr_torrent * tor, tr_piece_index_t pieceIndex, uint8_t * setme ) { - size_t bytesLeft; + static uint8_t * buf = NULL; + size_t bytesLeft; uint32_t offset = 0; - int success = TRUE; + int success = TRUE; SHA_CTX sha; + if( buf == NULL ) + buf = tr_new( uint8_t, TR_HASH_BUFSIZE ); + assert( tor ); assert( setme ); assert( pieceIndex < tor->info.pieceCount ); @@ -229,8 +239,7 @@ recalculateHash( const tr_torrent * tor, while( bytesLeft ) { - uint8_t buf[8192]; - const int len = MIN( bytesLeft, sizeof( buf ) ); + const int len = MIN( bytesLeft, TR_HASH_BUFSIZE ); success = !tr_ioRead( tor, pieceIndex, offset, len, buf ); if( !success ) break; -- 2.40.0