forked from premiere/premiere-libtorrent
remove build option to use narrower types in piece_picker (optimize_memory_usage)
This commit is contained in:
parent
e3c5a639ca
commit
09b5cfd688
3
Jamfile
3
Jamfile
|
@ -401,9 +401,6 @@ feature iconv : auto on off : composite propagated ;
|
||||||
feature.compose <iconv>on : <define>TORRENT_USE_ICONV=1 ;
|
feature.compose <iconv>on : <define>TORRENT_USE_ICONV=1 ;
|
||||||
feature.compose <iconv>off : <define>TORRENT_USE_ICONV=0 ;
|
feature.compose <iconv>off : <define>TORRENT_USE_ICONV=0 ;
|
||||||
|
|
||||||
feature memory-optimization : off on : composite propagated link-incompatible ;
|
|
||||||
feature.compose <memory-optimization>on : <define>TORRENT_OPTIMIZE_MEMORY_USAGE ;
|
|
||||||
|
|
||||||
feature asserts : off on production system : composite propagated ;
|
feature asserts : off on production system : composite propagated ;
|
||||||
feature.compose <asserts>on : <define>TORRENT_USE_ASSERTS=1 ;
|
feature.compose <asserts>on : <define>TORRENT_USE_ASSERTS=1 ;
|
||||||
feature.compose <asserts>production : <define>TORRENT_USE_ASSERTS=1 <define>TORRENT_PRODUCTION_ASSERTS=1 ;
|
feature.compose <asserts>production : <define>TORRENT_USE_ASSERTS=1 <define>TORRENT_PRODUCTION_ASSERTS=1 ;
|
||||||
|
|
|
@ -168,12 +168,7 @@ namespace libtorrent
|
||||||
|
|
||||||
int num_peers() const { return int(m_peers.size()); }
|
int num_peers() const { return int(m_peers.size()); }
|
||||||
|
|
||||||
#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE
|
|
||||||
using peers_t = std::vector<torrent_peer*>;
|
|
||||||
#else
|
|
||||||
using peers_t = std::deque<torrent_peer*>;
|
using peers_t = std::deque<torrent_peer*>;
|
||||||
#endif
|
|
||||||
|
|
||||||
using iterator = peers_t::iterator;
|
using iterator = peers_t::iterator;
|
||||||
using const_iterator = peers_t::const_iterator;
|
using const_iterator = peers_t::const_iterator;
|
||||||
iterator begin() { return m_peers.begin(); }
|
iterator begin() { return m_peers.begin(); }
|
||||||
|
|
|
@ -457,12 +457,13 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
piece_pos() {}
|
piece_pos() {}
|
||||||
piece_pos(int peer_count_, int index_)
|
piece_pos(int peer_count_, int index_)
|
||||||
: peer_count(unsigned(peer_count_))
|
: peer_count(static_cast<std::uint16_t>(peer_count_))
|
||||||
, download_state(piece_pos::piece_open)
|
, download_state(piece_pos::piece_open)
|
||||||
, piece_priority(4)
|
, piece_priority(4)
|
||||||
, index(unsigned(index_))
|
, index(index_)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(peer_count_ >= 0);
|
TORRENT_ASSERT(peer_count_ >= 0);
|
||||||
|
TORRENT_ASSERT(peer_count_ < std::numeric_limits<std::uint16_t>::max());
|
||||||
TORRENT_ASSERT(index_ >= 0);
|
TORRENT_ASSERT(index_ >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,11 +541,7 @@ namespace libtorrent
|
||||||
|
|
||||||
// the number of peers that has this piece
|
// the number of peers that has this piece
|
||||||
// (availability)
|
// (availability)
|
||||||
#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE
|
std::uint16_t peer_count = 0;
|
||||||
std::uint32_t peer_count : 9;
|
|
||||||
#else
|
|
||||||
std::uint32_t peer_count : 16;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// one of the enums from state_t. This indicates whether this piece
|
// one of the enums from state_t. This indicates whether this piece
|
||||||
// is currently being downloaded or not, and what state it's in if
|
// is currently being downloaded or not, and what state it's in if
|
||||||
|
@ -572,11 +569,7 @@ namespace libtorrent
|
||||||
std::uint32_t piece_priority : 3;
|
std::uint32_t piece_priority : 3;
|
||||||
|
|
||||||
// index in to the piece_info vector
|
// index in to the piece_info vector
|
||||||
#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE
|
|
||||||
std::uint32_t index : 17;
|
|
||||||
#else
|
|
||||||
std::uint32_t index;
|
std::uint32_t index;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef TORRENT_DEBUG_REFCOUNTS
|
#ifdef TORRENT_DEBUG_REFCOUNTS
|
||||||
// all the peers that have this piece
|
// all the peers that have this piece
|
||||||
|
@ -588,19 +581,11 @@ namespace libtorrent
|
||||||
// index is set to this to indicate that we have the
|
// index is set to this to indicate that we have the
|
||||||
// piece. There is no entry for the piece in the
|
// piece. There is no entry for the piece in the
|
||||||
// buckets if this is the case.
|
// buckets if this is the case.
|
||||||
#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE
|
|
||||||
we_have_index = 0x3ffff,
|
|
||||||
#else
|
|
||||||
we_have_index = 0xffffffff,
|
we_have_index = 0xffffffff,
|
||||||
#endif
|
|
||||||
// the priority value that means the piece is filtered
|
// the priority value that means the piece is filtered
|
||||||
filter_priority = 0,
|
filter_priority = 0,
|
||||||
// the max number the peer count can hold
|
// the max number the peer count can hold
|
||||||
#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE
|
|
||||||
max_peer_count = 0x1ff
|
|
||||||
#else
|
|
||||||
max_peer_count = 0xffff
|
max_peer_count = 0xffff
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool have() const { return index == we_have_index; }
|
bool have() const { return index == we_have_index; }
|
||||||
|
@ -668,11 +653,7 @@ namespace libtorrent
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef TORRENT_DEBUG_REFCOUNTS
|
#ifndef TORRENT_DEBUG_REFCOUNTS
|
||||||
#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE
|
|
||||||
static_assert(sizeof(piece_pos) == sizeof(char) * 4, "unexpected struct size");
|
|
||||||
#else
|
|
||||||
static_assert(sizeof(piece_pos) == sizeof(char) * 8, "unexpected struct size");
|
static_assert(sizeof(piece_pos) == sizeof(char) * 8, "unexpected struct size");
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool partial_compare_rarest_first(downloading_piece const* lhs
|
bool partial_compare_rarest_first(downloading_piece const* lhs
|
||||||
|
@ -797,11 +778,7 @@ namespace libtorrent
|
||||||
mutable bool m_dirty = false;
|
mutable bool m_dirty = false;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE
|
|
||||||
enum { max_pieces = piece_pos::we_have_index - 1 };
|
|
||||||
#else
|
|
||||||
enum { max_pieces = (std::numeric_limits<int>::max)() - 1 };
|
enum { max_pieces = (std::numeric_limits<int>::max)() - 1 };
|
||||||
#endif
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -424,20 +424,6 @@ namespace libtorrent
|
||||||
|
|
||||||
void piece_picker::check_invariant(torrent const* t) const
|
void piece_picker::check_invariant(torrent const* t) const
|
||||||
{
|
{
|
||||||
#ifndef TORRENT_DEBUG_REFCOUNTS
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(push)
|
|
||||||
#pragma warning(disable : 4127 ) /* warning C4127: conditional expression is constant */
|
|
||||||
#endif // _MSC_VER
|
|
||||||
#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE
|
|
||||||
TORRENT_ASSERT(sizeof(piece_pos) == 4);
|
|
||||||
#else
|
|
||||||
TORRENT_ASSERT(sizeof(piece_pos) == 8);
|
|
||||||
#endif
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(pop)
|
|
||||||
#endif // _MSC_VER
|
|
||||||
#endif
|
|
||||||
TORRENT_ASSERT(m_num_have >= 0);
|
TORRENT_ASSERT(m_num_have >= 0);
|
||||||
TORRENT_ASSERT(m_num_have_filtered >= 0);
|
TORRENT_ASSERT(m_num_have_filtered >= 0);
|
||||||
TORRENT_ASSERT(m_num_filtered >= 0);
|
TORRENT_ASSERT(m_num_filtered >= 0);
|
||||||
|
|
Loading…
Reference in New Issue