1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

(trunk libT) minor speedup tweaks in peer-request hotspots

This commit is contained in:
Charles Kerr 2009-01-04 18:01:15 +00:00
parent 6681107c00
commit 2eb1faa5e8
3 changed files with 6 additions and 8 deletions

View file

@ -358,8 +358,6 @@ ssize_t tr_peerIoFlush( tr_peerIo * io,
static inline struct evbuffer * tr_peerIoGetReadBuffer( tr_peerIo * io )
{
assert( tr_isPeerIo( io ) );
return io->inbuf;
}

View file

@ -25,20 +25,19 @@ compareRequests( const struct peer_request * a,
if( a->offset != b->offset )
return a->offset < b->offset ? -1 : 1;
if( a->length != b->length )
return a->length < b->length ? -1 : 1;
return 0;
}
const struct request_list REQUEST_LIST_INIT = { 0, 0, NULL, NULL };
static const int GROW = 8;
static void
reqListReserve( struct request_list * list, size_t max )
{
if( list->max < max )
{
list->max = max;
list->max = max + GROW;
list->fifo = tr_renew( struct peer_request, list->fifo, list->max );
list->sort = tr_renew( struct peer_request, list->sort, list->max );
}

View file

@ -1301,12 +1301,13 @@ tr_lowerBound( const void * key,
tr_bool * exact_match )
{
size_t first = 0;
const char * cbase = base;
while( nmemb > 0 )
while( nmemb )
{
const size_t half = nmemb / 2;
const size_t middle = first + half;
const int c = compar( key, ((const char*)base) + size*middle );
const int c = compar( key, cbase + size*middle );
if( c < 0 )
{