diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index 4b230e9fa..5ebc5919c 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -49,6 +49,7 @@ #include #include +#include #include #include #include @@ -94,7 +95,15 @@ namespace QString toString(const lt::tcp::endpoint <TCPEndpoint) { - return QString::fromStdString((std::stringstream() << ltTCPEndpoint).str()); + static QCache cache; + + if (const QString *endpointName = cache.object(ltTCPEndpoint)) + return *endpointName; + + const std::string tmp = (std::ostringstream() << ltTCPEndpoint).str(); + const auto endpointName = QString::fromLatin1(tmp.c_str(), tmp.size()); + cache.insert(ltTCPEndpoint, new QString(endpointName)); + return endpointName; } template