minor simplification of power-of-2 test in create_torrent

This commit is contained in:
arvidn 2019-04-27 10:45:31 +02:00 committed by Arvid Norberg
parent f21a39496d
commit b21eebbad7
1 changed files with 3 additions and 10 deletions

View File

@ -397,16 +397,9 @@ namespace {
alignment = piece_size;
// make sure the size is an even power of 2
#if TORRENT_USE_ASSERTS
for (int i = 0; i < 31; ++i)
{
if (piece_size & (1 << i))
{
TORRENT_ASSERT((piece_size & ~(1 << i)) == 0);
break;
}
}
#endif
// i.e. only a single bit is set
TORRENT_ASSERT((piece_size & (piece_size - 1)) == 0);
m_files.set_piece_length(piece_size);
if (flags & (optimize_alignment | mutable_torrent_support))
m_files.optimize(pad_file_limit, alignment, bool(flags & mutable_torrent_support));