summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-09-30 18:02:44 (GMT)
committerTobias Markmann <tm@ayena.de>2016-09-30 18:02:44 (GMT)
commit627e5feaab79101c58507dfaba492eb63d32cfa5 (patch)
tree4e061f47bcda5311bcd4c52b75855670546d338c
parent1e8670bd64efcc51cb435880a4e11337c56b1a0f (diff)
downloadswift-627e5feaab79101c58507dfaba492eb63d32cfa5.zip
swift-627e5feaab79101c58507dfaba492eb63d32cfa5.tar.bz2
Change custom memory copy loop to std::memcpy
Test-Information: Swift builds with test=all on macOS 10.12 and all tests pass. Change-Id: I9d7e8c49e65ac272a7ee672a95da5e24609d0a22
-rw-r--r--Swiften/Network/HostAddress.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/Swiften/Network/HostAddress.cpp b/Swiften/Network/HostAddress.cpp
index 7738079..a6c77f3 100644
--- a/Swiften/Network/HostAddress.cpp
+++ b/Swiften/Network/HostAddress.cpp
@@ -7,13 +7,9 @@
#include <Swiften/Network/HostAddress.h>
#include <cassert>
+#include <cstring>
#include <string>
-#include <boost/array.hpp>
-#include <boost/lexical_cast.hpp>
-#include <boost/numeric/conversion/cast.hpp>
-
-#include <Swiften/Base/foreach.h>
#include <Swiften/Base/Log.h>
static boost::asio::ip::address localhost4 = boost::asio::ip::address(boost::asio::ip::address_v4::loopback());
@@ -36,16 +32,12 @@ HostAddress::HostAddress(const unsigned char* address, size_t length) {
assert(length == 4 || length == 16);
if (length == 4) {
boost::asio::ip::address_v4::bytes_type data;
- for (size_t i = 0; i < length; ++i) {
- data[i] = address[i];
- }
+ std::memcpy(data.data(), address, length);
address_ = boost::asio::ip::address(boost::asio::ip::address_v4(data));
}
else {
boost::asio::ip::address_v6::bytes_type data;
- for (size_t i = 0; i < length; ++i) {
- data[i] = address[i];
- }
+ std::memcpy(data.data(), address, length);
address_ = boost::asio::ip::address(boost::asio::ip::address_v6(data));
}
}