Changeset 7119
- Timestamp:
- Nov 16, 2008, 8:56:18 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer-msgs.c
r7065 r7119 1848 1848 speed over a truly random sample -- let's limit the pool size to 1849 1849 the first 1000 pieces so large torrents don't bog things down */ 1850 size_t poolSize = MIN( msgs->torrent->info.pieceCount,1851 1852 tr_piece_index_t * pool = tr_new( tr_piece_index_t, poolSize );1850 size_t poolSize; 1851 const size_t maxPoolSize = MIN( msgs->torrent->info.pieceCount, 1000 ); 1852 tr_piece_index_t * pool = tr_new( tr_piece_index_t, maxPoolSize ); 1853 1853 1854 1854 /* build the pool */ 1855 for( i = 0; i < poolSize; ++i ) 1856 pool[i] = i; 1855 for( i=poolSize=0; i<maxPoolSize; ++i ) 1856 if( tr_bitfieldHas( field, i ) ) 1857 pool[poolSize++] = i; 1857 1858 1858 1859 /* pull random piece indices from the pool */ 1859 1860 while( ( poolSize > 0 ) && ( lazyCount < LAZY_PIECE_COUNT ) ) 1860 1861 { 1861 const int 1862 const int pos = tr_cryptoWeakRandInt( poolSize ); 1862 1863 const tr_piece_index_t piece = pool[pos]; 1863 1864 tr_bitfieldRem( field, piece );
Note: See TracChangeset
for help on using the changeset viewer.