mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 14:57:52 +00:00
Reserve memory for file data buffers
This commit is contained in:
parent
c73d698718
commit
e262b86c44
@ -3507,6 +3507,7 @@ void Session::handleTorrentResumeDataReady(TorrentHandle *const torrent, const l
|
||||
// isn't cheap too.
|
||||
|
||||
QByteArray out;
|
||||
out.reserve(1024 * 1024); // most fastresume file sizes are under 1 MB
|
||||
lt::bencode(std::back_inserter(out), data);
|
||||
|
||||
const QString filename = QString("%1.fastresume").arg(torrent->hash());
|
||||
|
@ -1581,11 +1581,15 @@ bool TorrentHandle::saveTorrentFile(const QString &path)
|
||||
#endif
|
||||
const lt::entry torrentEntry = torrentCreator.generate();
|
||||
|
||||
QVector<char> out;
|
||||
QByteArray out;
|
||||
out.reserve(1024 * 1024); // most torrent file sizes are under 1 MB
|
||||
lt::bencode(std::back_inserter(out), torrentEntry);
|
||||
if (out.isEmpty())
|
||||
return false;
|
||||
|
||||
QFile torrentFile(path);
|
||||
if (!out.empty() && torrentFile.open(QIODevice::WriteOnly))
|
||||
return (torrentFile.write(&out[0], out.size()) == out.size());
|
||||
if (torrentFile.open(QIODevice::WriteOnly))
|
||||
return (torrentFile.write(out) == out.size());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user