clean up in piece picker

This commit is contained in:
arvidn 2016-04-06 00:45:21 -04:00
parent f5c3c6addc
commit 387498e54f
2 changed files with 7 additions and 14 deletions

@ -1 +1 @@
Subproject commit 0151d5c17fa3f4cf0ce518d0b8f90a23792c9b24
Subproject commit 66356b0ce99cd126c7c99df50609b3050ba44e5d

View File

@ -1893,21 +1893,15 @@ namespace libtorrent
namespace
{
int append_blocks(std::vector<piece_block>& dst, std::vector<piece_block>& src
, int num_blocks)
, int const num_blocks)
{
if (src.empty()) return num_blocks;
int to_copy;
// if (prefer_contiguous_blocks == 0)
to_copy = (std::min)(int(src.size()), num_blocks);
// else
// to_copy = int(src.size());
int const to_copy = (std::min)(int(src.size()), num_blocks);
dst.insert(dst.end()
, src.begin(), src.begin() + to_copy);
src.clear();
dst.insert(dst.end(), src.begin(), src.begin() + to_copy);
src.erase(src.begin(), src.begin() + to_copy);
return num_blocks - to_copy;
}
}
// lower availability comes first. This is a less-than comparison, it returns
@ -2338,8 +2332,7 @@ get_out:
#endif
ret |= picker_log_alert::backup1;
num_blocks = append_blocks(interesting_blocks, backup_blocks
, num_blocks);
num_blocks = append_blocks(interesting_blocks, backup_blocks, num_blocks);
if (num_blocks <= 0) return ret;
ret |= picker_log_alert::backup2;
@ -2390,7 +2383,7 @@ get_out:
// we either don't have this piece, or we've already requested from it
if (!pieces[dp.index]) continue;
// if we already have the piece, obviously we should not have
// if we already have the piece, obviously we should not have
// since this is a partial piece in the piece_downloading state, we
// should not already have it
TORRENT_ASSERT(!m_piece_map[dp.index].have());