From d202c5eceae2747d600592a663c0416eed089fcf Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 2 Jan 2009 20:19:10 +0000 Subject: [PATCH] (trunk libT) inline the ptrarray one-liners --- libtransmission/peer-mgr.c | 2 +- libtransmission/ptrarray.c | 31 ------------------------------- libtransmission/ptrarray.h | 22 +++++++++++++++------- 3 files changed, 16 insertions(+), 39 deletions(-) diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index fef7c84ec..505d969aa 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -790,7 +790,7 @@ refillPulse( void * vtorrent ) blockIterator = blockIteratorNew( t ); peers = getPeersUploadingToClient( t, &peerCount ); webseedCount = tr_ptrArraySize( &t->webseeds ); - webseeds = tr_memdup( tr_ptrArrayBase( &t->webseeds ), + webseeds = tr_memdup( TR_PTR_ARRAY_DATA( &t->webseeds ), webseedCount * sizeof( tr_webseed* ) ); while( ( webseedCount || peerCount ) diff --git a/libtransmission/ptrarray.c b/libtransmission/ptrarray.c index 730a99c9f..13b4ec30c 100644 --- a/libtransmission/ptrarray.c +++ b/libtransmission/ptrarray.c @@ -85,12 +85,6 @@ tr_ptrArrayPeek( tr_ptrArray * t, return t->items; } -void** -tr_ptrArrayBase( tr_ptrArray * t ) -{ - return t->items; -} - void* tr_ptrArrayNth( tr_ptrArray* t, int i ) @@ -110,24 +104,6 @@ tr_ptrArrayBack( tr_ptrArray* t ) return tr_ptrArrayNth( t, t->n_items - 1 ); } -int -tr_ptrArraySize( const tr_ptrArray * t ) -{ - return t->n_items; -} - -int -tr_ptrArrayEmpty( const tr_ptrArray * t ) -{ - return t->n_items == 0; -} - -void -tr_ptrArrayClear( tr_ptrArray * t ) -{ - t->n_items = 0; -} - int tr_ptrArrayInsert( tr_ptrArray * t, void * ptr, @@ -151,13 +127,6 @@ tr_ptrArrayInsert( tr_ptrArray * t, return pos; } -int -tr_ptrArrayAppend( tr_ptrArray * t, - void * ptr ) -{ - return tr_ptrArrayInsert( t, ptr, -1 ); -} - void* tr_ptrArrayPop( tr_ptrArray* t ) { diff --git a/libtransmission/ptrarray.h b/libtransmission/ptrarray.h index 15b4b5538..83a16e08f 100644 --- a/libtransmission/ptrarray.h +++ b/libtransmission/ptrarray.h @@ -29,6 +29,8 @@ #ifndef _TR_PTR_ARRAY_H_ #define _TR_PTR_ARRAY_H_ +#include "transmission.h" + /** * A simple pointer array that resizes itself dynamically. */ @@ -67,16 +69,16 @@ void* tr_ptrArrayBack( tr_ptrArray * array ); void** tr_ptrArrayPeek( tr_ptrArray * array, int * size ); -void** tr_ptrArrayBase( tr_ptrArray * array ); - -void tr_ptrArrayClear( tr_ptrArray * array ); +static inline void tr_ptrArrayClear( tr_ptrArray * a ) { a->n_items = 0; } int tr_ptrArrayInsert( tr_ptrArray * array, void * insertMe, int pos ); -int tr_ptrArrayAppend( tr_ptrArray * array, - void * appendMe ); +static inline int tr_ptrArrayAppend( tr_ptrArray * array, void * appendMe ) +{ + return tr_ptrArrayInsert( array, appendMe, -1 ); +} void* tr_ptrArrayPop( tr_ptrArray * array ); @@ -84,9 +86,15 @@ void tr_ptrArrayErase( tr_ptrArray * array, int begin, int end ); -int tr_ptrArraySize( const tr_ptrArray* ); +static inline int tr_ptrArraySize( const tr_ptrArray * a ) +{ + return a->n_items; +} -int tr_ptrArrayEmpty( const tr_ptrArray* ); +static inline tr_bool tr_ptrArrayEmpty( const tr_ptrArray * a ) +{ + return tr_ptrArraySize(a) == 0; +} int tr_ptrArrayInsertSorted( tr_ptrArray * array, void * value,