#4496 'freeze when having a huge torrent' -- remove redundant debug calls to countArray(). This is a second iteration of optimizations based on MechMK1's Shark report.
This commit is contained in:
parent
3a3cef615c
commit
6f05024dab
|
@ -185,8 +185,6 @@ tr_bitfieldEnsureBitsAlloced( tr_bitfield * b, size_t nth )
|
||||||
size_t bytes_needed;
|
size_t bytes_needed;
|
||||||
const bool has_all = tr_bitfieldHasAll( b );
|
const bool has_all = tr_bitfieldHasAll( b );
|
||||||
|
|
||||||
assert( tr_bitfieldIsValid( b ) );
|
|
||||||
|
|
||||||
if( has_all )
|
if( has_all )
|
||||||
bytes_needed = get_bytes_needed( MAX( nth, b->true_count ) + 1 );
|
bytes_needed = get_bytes_needed( MAX( nth, b->true_count ) + 1 );
|
||||||
else
|
else
|
||||||
|
@ -194,13 +192,9 @@ tr_bitfieldEnsureBitsAlloced( tr_bitfield * b, size_t nth )
|
||||||
|
|
||||||
if( b->alloc_count < bytes_needed )
|
if( b->alloc_count < bytes_needed )
|
||||||
{
|
{
|
||||||
#ifndef NDEBUG
|
|
||||||
const size_t old_count = countArray( b );
|
|
||||||
#endif
|
|
||||||
b->bits = tr_renew( uint8_t, b->bits, bytes_needed );
|
b->bits = tr_renew( uint8_t, b->bits, bytes_needed );
|
||||||
memset( b->bits + b->alloc_count, 0, bytes_needed - b->alloc_count );
|
memset( b->bits + b->alloc_count, 0, bytes_needed - b->alloc_count );
|
||||||
b->alloc_count = bytes_needed;
|
b->alloc_count = bytes_needed;
|
||||||
assert( old_count == countArray( b ) );
|
|
||||||
|
|
||||||
if( has_all )
|
if( has_all )
|
||||||
set_all_true( b->bits, b->true_count );
|
set_all_true( b->bits, b->true_count );
|
||||||
|
|
Loading…
Reference in New Issue