(libT) more dead code removal: tr_compareUint32(), tr_compareUint64(), tr_strcmp(), tr_strcasecmp()

This commit is contained in:
Charles Kerr 2008-08-22 14:52:20 +00:00
parent 7f749d1284
commit ef68e36a0d
5 changed files with 26 additions and 57 deletions

View File

@ -393,6 +393,15 @@ tr_core_apply_defaults( tr_ctor * ctor )
}
}
static int
tr_strcmp( const void * a, const void * b )
{
if( a && b ) return strcmp( a, b );
if( a ) return 1;
if( b ) return -1;
return 0;
}
#ifdef HAVE_GIO
static gboolean
watchFolderIdle( gpointer gcore )

View File

@ -120,12 +120,18 @@ struct peer_request
static int
compareRequest( const void * va, const void * vb )
{
int i;
const struct peer_request * a = va;
const struct peer_request * b = vb;
if(( i = tr_compareUint32( a->index, b->index ))) return i;
if(( i = tr_compareUint32( a->offset, b->offset ))) return i;
if(( i = tr_compareUint32( a->length, b->length ))) return i;
if( a->index != b->index )
return a->index < b->index ? -1 : 1;
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;
}

View File

@ -490,14 +490,18 @@ tr_sessionCountTorrents( const tr_handle * h )
return h->torrentCount;
}
/* close the biggest torrents first */
static int
compareTorrentByCur( const void * va, const void * vb )
{
const tr_torrent * a = *(const tr_torrent**)va;
const tr_torrent * b = *(const tr_torrent**)vb;
return -tr_compareUint64( a->downloadedCur + a->uploadedCur,
b->downloadedCur + b->uploadedCur );
const uint64_t aCur = a->downloadedCur + a->uploadedCur;
const uint64_t bCur = b->downloadedCur + b->uploadedCur;
if( aCur != bCur )
return aCur > bCur ? -1 : 1; /* close the biggest torrents first */
return 0;
}
static void

View File

@ -325,50 +325,6 @@ tr_set_compare( const void * va, size_t aCount,
****
***/
int
tr_compareUint32( uint32_t a, uint32_t b )
{
if( a < b ) return -1;
if( a > b ) return 1;
return 0;
}
int
tr_compareUint64( uint64_t a, uint64_t b )
{
if( a < b ) return -1;
if( a > b ) return 1;
return 0;
}
int
tr_strcmp( const void * a, const void * b )
{
if( a && b ) return strcmp( a, b );
if( a ) return 1;
if( b ) return -1;
return 0;
}
int
tr_strcasecmp( const char * a, const char * b )
{
if( !a && !b ) return 0;
if( !a ) return -1;
if( !b ) return 1;
#ifdef HAVE_STRCASECMP
return strcasecmp( a, b );
#else
while( *a && ( tolower( *(uint8_t*)a ) == tolower( *(uint8_t*)b ) ) )
++a, ++b;
return tolower( *(uint8_t*)a) - tolower(*(uint8_t*)b );
#endif
}
/**
***
**/
#ifdef DISABLE_GETTEXT
const char*

View File

@ -219,12 +219,6 @@ void tr_set_compare( const void * a, size_t aCount,
tr_set_func in_both_cb,
void * userData );
int tr_compareUint32( uint32_t a, uint32_t b );
int tr_compareUint64( uint64_t a, uint64_t b );
int tr_strcmp( const void * a, const void * b );
int tr_strcasecmp( const char * a, const char * b );
void tr_sha1_to_hex( char * out, const uint8_t * sha1 );