From 2a66bb31272ee0428f064b401847857108691fc3 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 31 Aug 2019 20:47:44 +0800 Subject: [PATCH] Construct QHostAddress more efficiently --- src/base/bittorrent/peerinfo.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/base/bittorrent/peerinfo.cpp b/src/base/bittorrent/peerinfo.cpp index 637ac7b36..60d0fc4b8 100644 --- a/src/base/bittorrent/peerinfo.cpp +++ b/src/base/bittorrent/peerinfo.cpp @@ -168,8 +168,11 @@ bool PeerInfo::isPlaintextEncrypted() const PeerAddress PeerInfo::address() const { - return {QHostAddress(QString::fromStdString(m_nativeInfo.ip.address().to_string())) - , m_nativeInfo.ip.port()}; + // fast path for platforms which boost.asio internal struct maps to `sockaddr` + return {QHostAddress(m_nativeInfo.ip.data()), m_nativeInfo.ip.port()}; + // slow path for the others + //return {QHostAddress(QString::fromStdString(m_nativeInfo.ip.address().to_string())) + // , m_nativeInfo.ip.port()}; } QString PeerInfo::client() const