diff --git a/Jamfile b/Jamfile index 166fb7838..4023ee35e 100644 --- a/Jamfile +++ b/Jamfile @@ -401,9 +401,6 @@ feature iconv : auto on off : composite propagated ; feature.compose on : TORRENT_USE_ICONV=1 ; feature.compose off : TORRENT_USE_ICONV=0 ; -feature memory-optimization : off on : composite propagated link-incompatible ; -feature.compose on : TORRENT_OPTIMIZE_MEMORY_USAGE ; - feature asserts : off on production system : composite propagated ; feature.compose on : TORRENT_USE_ASSERTS=1 ; feature.compose production : TORRENT_USE_ASSERTS=1 TORRENT_PRODUCTION_ASSERTS=1 ; diff --git a/include/libtorrent/peer_list.hpp b/include/libtorrent/peer_list.hpp index 94c2a5522..b1cd4b7b9 100644 --- a/include/libtorrent/peer_list.hpp +++ b/include/libtorrent/peer_list.hpp @@ -168,12 +168,7 @@ namespace libtorrent int num_peers() const { return int(m_peers.size()); } -#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE - using peers_t = std::vector; -#else using peers_t = std::deque; -#endif - using iterator = peers_t::iterator; using const_iterator = peers_t::const_iterator; iterator begin() { return m_peers.begin(); } diff --git a/include/libtorrent/piece_picker.hpp b/include/libtorrent/piece_picker.hpp index 672fd694c..a69d20c1f 100644 --- a/include/libtorrent/piece_picker.hpp +++ b/include/libtorrent/piece_picker.hpp @@ -457,12 +457,13 @@ namespace libtorrent { piece_pos() {} piece_pos(int peer_count_, int index_) - : peer_count(unsigned(peer_count_)) + : peer_count(static_cast(peer_count_)) , download_state(piece_pos::piece_open) , piece_priority(4) - , index(unsigned(index_)) + , index(index_) { TORRENT_ASSERT(peer_count_ >= 0); + TORRENT_ASSERT(peer_count_ < std::numeric_limits::max()); TORRENT_ASSERT(index_ >= 0); } @@ -540,11 +541,7 @@ namespace libtorrent // the number of peers that has this piece // (availability) -#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE - std::uint32_t peer_count : 9; -#else - std::uint32_t peer_count : 16; -#endif + std::uint16_t peer_count = 0; // 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 @@ -572,11 +569,7 @@ namespace libtorrent std::uint32_t piece_priority : 3; // index in to the piece_info vector -#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE - std::uint32_t index : 17; -#else std::uint32_t index; -#endif #ifdef TORRENT_DEBUG_REFCOUNTS // all the peers that have this piece @@ -588,19 +581,11 @@ namespace libtorrent // index is set to this to indicate that we have the // piece. There is no entry for the piece in the // buckets if this is the case. -#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE - we_have_index = 0x3ffff, -#else we_have_index = 0xffffffff, -#endif // the priority value that means the piece is filtered filter_priority = 0, // the max number the peer count can hold -#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE - max_peer_count = 0x1ff -#else max_peer_count = 0xffff -#endif }; bool have() const { return index == we_have_index; } @@ -668,11 +653,7 @@ namespace libtorrent }; #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"); -#endif #endif bool partial_compare_rarest_first(downloading_piece const* lhs @@ -797,11 +778,7 @@ namespace libtorrent mutable bool m_dirty = false; public: -#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE - enum { max_pieces = piece_pos::we_have_index - 1 }; -#else enum { max_pieces = (std::numeric_limits::max)() - 1 }; -#endif }; } diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index 4427ca7a5..467c9405c 100644 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -424,20 +424,6 @@ namespace libtorrent 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_filtered >= 0); TORRENT_ASSERT(m_num_filtered >= 0);