avoid endianness test in peer_priority function
This commit is contained in:
parent
f8988231a3
commit
fe9883ea27
|
@ -36,8 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/peer_connection.hpp"
|
#include "libtorrent/peer_connection.hpp"
|
||||||
#include "libtorrent/crc32c.hpp"
|
#include "libtorrent/crc32c.hpp"
|
||||||
#include "libtorrent/ip_voter.hpp"
|
#include "libtorrent/ip_voter.hpp"
|
||||||
|
#include "libtorrent/io.hpp" // for write_uint16
|
||||||
#include <boost/detail/endian.hpp> // for BIG_ENDIAN and LITTLE_ENDIAN macros
|
|
||||||
|
|
||||||
namespace libtorrent {
|
namespace libtorrent {
|
||||||
|
|
||||||
|
@ -84,15 +83,9 @@ namespace libtorrent {
|
||||||
if (e1.port() > e2.port())
|
if (e1.port() > e2.port())
|
||||||
swap(e1, e2);
|
swap(e1, e2);
|
||||||
std::uint32_t p;
|
std::uint32_t p;
|
||||||
#if defined BOOST_BIG_ENDIAN
|
auto ptr = reinterpret_cast<char*>(&p);
|
||||||
p = std::uint32_t(e1.port() << 16);
|
detail::write_uint16(e1.port(), ptr);
|
||||||
p |= e2.port();
|
detail::write_uint16(e2.port(), ptr);
|
||||||
#elif defined BOOST_LITTLE_ENDIAN
|
|
||||||
p = std::uint32_t(aux::host_to_network(e2.port()) << 16);
|
|
||||||
p |= aux::host_to_network(e1.port());
|
|
||||||
#else
|
|
||||||
#error unsupported endianness
|
|
||||||
#endif
|
|
||||||
ret = crc32c_32(p);
|
ret = crc32c_32(p);
|
||||||
}
|
}
|
||||||
#if TORRENT_USE_IPV6
|
#if TORRENT_USE_IPV6
|
||||||
|
|
Loading…
Reference in New Issue