mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-21 08:09:35 +08:00
Merge pull request #12108 from Chocobo1/bits
Avoid unnecessary memory writes
This commit is contained in:
commit
ca01b049a6
@ -208,11 +208,10 @@ qlonglong PeerInfo::totalDownload() const
|
||||
QBitArray PeerInfo::pieces() const
|
||||
{
|
||||
QBitArray result(m_nativeInfo.pieces.size());
|
||||
|
||||
int i = 0;
|
||||
for (const bool bit : m_nativeInfo.pieces)
|
||||
result.setBit(i++, bit);
|
||||
|
||||
for (int i = 0; i < result.size(); ++i) {
|
||||
if (m_nativeInfo.pieces[i])
|
||||
result.setBit(i, true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1202,10 +1202,10 @@ QVector<PeerInfo> TorrentHandle::peers() const
|
||||
QBitArray TorrentHandle::pieces() const
|
||||
{
|
||||
QBitArray result(m_nativeStatus.pieces.size());
|
||||
|
||||
for (int i = 0; i < m_nativeStatus.pieces.size(); ++i)
|
||||
result.setBit(i, m_nativeStatus.pieces.get_bit(LTPieceIndex {i}));
|
||||
|
||||
for (int i = 0; i < result.size(); ++i) {
|
||||
if (m_nativeStatus.pieces[LTPieceIndex {i}])
|
||||
result.setBit(i, true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user