From fe9883ea27f25b74acda7f577ec529724ecac909 Mon Sep 17 00:00:00 2001 From: Alden Torres Date: Wed, 31 Jan 2018 09:23:30 -0500 Subject: [PATCH] avoid endianness test in peer_priority function --- src/torrent_peer.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/torrent_peer.cpp b/src/torrent_peer.cpp index 222964acb..a363bbec4 100644 --- a/src/torrent_peer.cpp +++ b/src/torrent_peer.cpp @@ -36,8 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_connection.hpp" #include "libtorrent/crc32c.hpp" #include "libtorrent/ip_voter.hpp" - -#include // for BIG_ENDIAN and LITTLE_ENDIAN macros +#include "libtorrent/io.hpp" // for write_uint16 namespace libtorrent { @@ -84,15 +83,9 @@ namespace libtorrent { if (e1.port() > e2.port()) swap(e1, e2); std::uint32_t p; -#if defined BOOST_BIG_ENDIAN - p = std::uint32_t(e1.port() << 16); - p |= e2.port(); -#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 + auto ptr = reinterpret_cast(&p); + detail::write_uint16(e1.port(), ptr); + detail::write_uint16(e2.port(), ptr); ret = crc32c_32(p); } #if TORRENT_USE_IPV6