(trunk libT) #2775 "Saving some memory/storage" -- committed for 1.80
This commit is contained in:
parent
8a49d60f6f
commit
8e16b74dad
|
@ -154,7 +154,7 @@ enum classes {
|
|||
NR_CLASSES
|
||||
};
|
||||
|
||||
static int ascii_class[128] = {
|
||||
static const int ascii_class[128] = {
|
||||
/*
|
||||
This array maps the 128 ASCII characters into character classes.
|
||||
The remaining Unicode characters should be mapped to C_ETC.
|
||||
|
@ -243,7 +243,7 @@ enum actions
|
|||
};
|
||||
|
||||
|
||||
static int state_transition_table[NR_STATES][NR_CLASSES] = {
|
||||
static const int state_transition_table[NR_STATES][NR_CLASSES] = {
|
||||
/*
|
||||
The state transition table takes the current state and the current symbol,
|
||||
and returns either a new state or an action. An action is represented as a
|
||||
|
@ -523,7 +523,7 @@ static int parse_parse_buffer(JSON_parser jc)
|
|||
#define IS_HIGH_SURROGATE(uc) (((uc) & 0xFC00) == 0xD800)
|
||||
#define IS_LOW_SURROGATE(uc) (((uc) & 0xFC00) == 0xDC00)
|
||||
#define DECODE_SURROGATE_PAIR(hi,lo) ((((hi) & 0x3FF) << 10) + ((lo) & 0x3FF) + 0x10000)
|
||||
static unsigned char utf8_lead_bits[4] = { 0x00, 0xC0, 0xE0, 0xF0 };
|
||||
static const unsigned char utf8_lead_bits[4] = { 0x00, 0xC0, 0xE0, 0xF0 };
|
||||
|
||||
static int decode_unicode_char(JSON_parser jc)
|
||||
{
|
||||
|
|
|
@ -190,7 +190,7 @@ tr_bitfieldCountTrueBits( const tr_bitfield* b )
|
|||
{
|
||||
size_t ret = 0;
|
||||
const uint8_t * it, *end;
|
||||
static const int trueBitCount[512] = {
|
||||
static const int trueBitCount[256] = {
|
||||
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3,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 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
|
||||
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, 5, 6, 6, 7, 6, 7, 7, 8, 6, 7, 7, 8, 7, 8, 8, 9
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
|
||||
};
|
||||
|
||||
if( !b )
|
||||
|
|
|
@ -375,8 +375,8 @@ tr_ssha1( const void * plaintext )
|
|||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"./";
|
||||
static const size_t salter_len = 64;
|
||||
static const size_t saltval_len = 8;
|
||||
const size_t salter_len = 64;
|
||||
const size_t saltval_len = 8;
|
||||
|
||||
size_t i;
|
||||
char salt[saltval_len];
|
||||
|
|
|
@ -90,9 +90,9 @@ getFiles( const char * dir,
|
|||
static int
|
||||
bestPieceSize( uint64_t totalSize )
|
||||
{
|
||||
static const uint64_t GiB = 1073741824;
|
||||
static const uint64_t MiB = 1048576;
|
||||
static const uint64_t KiB = 1024;
|
||||
const uint64_t GiB = 1073741824;
|
||||
const uint64_t MiB = 1048576;
|
||||
const uint64_t KiB = 1024;
|
||||
|
||||
if( totalSize >= ( 2 * GiB ) ) return 2 * MiB;
|
||||
if( totalSize >= ( 1 * GiB ) ) return 1 * MiB;
|
||||
|
|
|
@ -57,7 +57,7 @@ guessPacketOverhead( size_t d )
|
|||
* (1500-72)/(38+1500) = 92.8479 % IPv6, TCP timestamps
|
||||
* (1500-72)/(42+1500) = 92.6070 % 802.1q, IPv6, ICP timestamps
|
||||
*/
|
||||
static const double assumed_payload_data_rate = 94.0;
|
||||
const double assumed_payload_data_rate = 94.0;
|
||||
|
||||
return (size_t)( d * ( 100.0 / assumed_payload_data_rate ) - d );
|
||||
}
|
||||
|
|
|
@ -1120,22 +1120,24 @@ refillUpkeep( int foo UNUSED, short bar UNUSED, void * vmgr )
|
|||
{
|
||||
int keepCount = 0;
|
||||
int cancelCount = 0;
|
||||
struct block_request * keep = tr_new( struct block_request, n );
|
||||
struct block_request * cancel = tr_new( struct block_request, n );
|
||||
const struct block_request * it;
|
||||
const struct block_request * end;
|
||||
|
||||
for( it=t->requests, end=it+n; it!=end; ++it )
|
||||
{
|
||||
if( it->sentAt <= too_old )
|
||||
cancel[cancelCount++] = *it;
|
||||
else
|
||||
keep[keepCount++] = *it;
|
||||
{
|
||||
if( it != &t->requests[keepCount] )
|
||||
t->requests[keepCount] = *it;
|
||||
keepCount++;
|
||||
}
|
||||
}
|
||||
|
||||
/* prune out the ones we aren't keeping */
|
||||
tr_free( t->requests );
|
||||
t->requests = keep;
|
||||
t->requestCount = keepCount;
|
||||
t->requestAlloc = n;
|
||||
|
||||
/* send cancel messages for all the "cancel" ones */
|
||||
for( it=cancel, end=it+cancelCount; it!=end; ++it )
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
****
|
||||
***/
|
||||
|
||||
static struct tr_session_stats STATS_INIT = { 0.0f, 0, 0, 0, 0, 0 };
|
||||
static const struct tr_session_stats STATS_INIT = { 0.0f, 0, 0, 0, 0, 0 };
|
||||
|
||||
/** @brief Opaque, per-session data structure for bandwidth use statistics */
|
||||
struct tr_stats_handle
|
||||
|
|
Loading…
Reference in New Issue