mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 21:33:27 -07:00
Initialize class variable in initializer list
This commit is contained in:
parent
ff99e5ac9a
commit
53992bf0d5
2 changed files with 5 additions and 8 deletions
|
@ -39,8 +39,8 @@ using namespace BitTorrent;
|
||||||
|
|
||||||
PeerInfo::PeerInfo(const Torrent *torrent, const lt::peer_info &nativeInfo)
|
PeerInfo::PeerInfo(const Torrent *torrent, const lt::peer_info &nativeInfo)
|
||||||
: m_nativeInfo(nativeInfo)
|
: m_nativeInfo(nativeInfo)
|
||||||
|
, m_relevance(calcRelevance(torrent))
|
||||||
{
|
{
|
||||||
calcRelevance(torrent);
|
|
||||||
determineFlags();
|
determineFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,19 +226,16 @@ QString PeerInfo::connectionType() const
|
||||||
: QLatin1String {"Web"};
|
: QLatin1String {"Web"};
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerInfo::calcRelevance(const Torrent *torrent)
|
qreal PeerInfo::calcRelevance(const Torrent *torrent) const
|
||||||
{
|
{
|
||||||
const QBitArray allPieces = torrent->pieces();
|
const QBitArray allPieces = torrent->pieces();
|
||||||
const int localMissing = allPieces.count(false);
|
const int localMissing = allPieces.count(false);
|
||||||
if (localMissing <= 0)
|
if (localMissing <= 0)
|
||||||
{
|
return 0;
|
||||||
m_relevance = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QBitArray peerPieces = pieces();
|
const QBitArray peerPieces = pieces();
|
||||||
const int remoteHaves = (peerPieces & (~allPieces)).count(true);
|
const int remoteHaves = (peerPieces & (~allPieces)).count(true);
|
||||||
m_relevance = static_cast<qreal>(remoteHaves) / localMissing;
|
return static_cast<qreal>(remoteHaves) / localMissing;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal PeerInfo::relevance() const
|
qreal PeerInfo::relevance() const
|
||||||
|
|
|
@ -92,7 +92,7 @@ namespace BitTorrent
|
||||||
int downloadingPieceIndex() const;
|
int downloadingPieceIndex() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void calcRelevance(const Torrent *torrent);
|
qreal calcRelevance(const Torrent *torrent) const;
|
||||||
void determineFlags();
|
void determineFlags();
|
||||||
|
|
||||||
lt::peer_info m_nativeInfo = {};
|
lt::peer_info m_nativeInfo = {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue