mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-30 16:34:16 +00:00
Avoid unnecessary memory writes
Before this change, qbt spent ~1% in these two functions, now it only spends about ~0.5% in my naive testing.
This commit is contained in:
parent
b519ece18b
commit
24cd7c3611
@ -208,11 +208,10 @@ qlonglong PeerInfo::totalDownload() const
|
|||||||
QBitArray PeerInfo::pieces() const
|
QBitArray PeerInfo::pieces() const
|
||||||
{
|
{
|
||||||
QBitArray result(m_nativeInfo.pieces.size());
|
QBitArray result(m_nativeInfo.pieces.size());
|
||||||
|
for (int i = 0; i < result.size(); ++i) {
|
||||||
int i = 0;
|
if (m_nativeInfo.pieces[i])
|
||||||
for (const bool bit : m_nativeInfo.pieces)
|
result.setBit(i, true);
|
||||||
result.setBit(i++, bit);
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1202,10 +1202,10 @@ QVector<PeerInfo> TorrentHandle::peers() const
|
|||||||
QBitArray TorrentHandle::pieces() const
|
QBitArray TorrentHandle::pieces() const
|
||||||
{
|
{
|
||||||
QBitArray result(m_nativeStatus.pieces.size());
|
QBitArray result(m_nativeStatus.pieces.size());
|
||||||
|
for (int i = 0; i < result.size(); ++i) {
|
||||||
for (int i = 0; i < m_nativeStatus.pieces.size(); ++i)
|
if (m_nativeStatus.pieces[LTPieceIndex {i}])
|
||||||
result.setBit(i, m_nativeStatus.pieces.get_bit(LTPieceIndex {i}));
|
result.setBit(i, true);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user