From e7890fb727b16fa19c3863dace0a71a14d20c17e Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 8 Apr 2020 12:45:03 +0800 Subject: [PATCH] Preallocate output buffer --- src/base/bittorrent/session.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index eaa4e6e3f..55a2052a6 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -2587,6 +2587,7 @@ void Session::saveResumeData() void Session::saveTorrentsQueue() { + // store hash in textual representation QMap queue; // Use QMap since it should be ordered by key for (const TorrentHandle *torrent : asConst(torrents())) { // We require actual (non-cached) queue position here! @@ -2596,6 +2597,7 @@ void Session::saveTorrentsQueue() } QByteArray data; + data.reserve(((InfoHash::length() * 2) + 1) * queue.size()); for (const QString &hash : asConst(queue)) data += (hash.toLatin1() + '\n');