From d3c14454198d126a8d92c51a917fff556bdd596c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Sun, 19 Feb 2023 20:14:26 +0100 Subject: [PATCH] Torrent: simplify QBitArray usage There is specific API for counting number of 0-bits Pick-to: 6.5 Task-number: QTBUG-110622 Change-Id: Ifa33862ff7b98a59f362bc52c492e8a037799835 Reviewed-by: Konrad Kujawa Reviewed-by: Timur Pocheptsov --- examples/network/torrent/torrentclient.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/examples/network/torrent/torrentclient.cpp b/examples/network/torrent/torrentclient.cpp index 4ae1debcb3..5b6edc6dad 100644 --- a/examples/network/torrent/torrentclient.cpp +++ b/examples/network/torrent/torrentclient.cpp @@ -1024,13 +1024,7 @@ void TorrentClient::peerWireBytesReceived(qint64 size) int TorrentClient::blocksLeftForPiece(const TorrentPiece *piece) const { - int blocksLeft = 0; - int completedBlocksSize = piece->completedBlocks.size(); - for (int i = 0; i < completedBlocksSize; ++i) { - if (!piece->completedBlocks.testBit(i)) - ++blocksLeft; - } - return blocksLeft; + return piece->completedBlocks.count(false); } void TorrentClient::scheduleUploads()