mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-03 02:14:16 +00:00
fewer calls to hash()
This commit is contained in:
parent
5d2663660d
commit
bbc4080a5d
@ -335,7 +335,7 @@ void PropertiesWidget::loadDynamicData() {
|
|||||||
// Update next announce time
|
// Update next announce time
|
||||||
reannounce_lbl->setText(h.next_announce());
|
reannounce_lbl->setText(h.next_announce());
|
||||||
// Update ratio info
|
// Update ratio info
|
||||||
const qreal ratio = QBtSession::instance()->getRealRatio(h.hash());
|
const qreal ratio = QBtSession::instance()->getRealRatio(h);
|
||||||
shareRatio->setText(ratio > QBtSession::MAX_RATIO ? QString::fromUtf8("∞") : misc::accurateDoubleToString(ratio, 2));
|
shareRatio->setText(ratio > QBtSession::MAX_RATIO ? QString::fromUtf8("∞") : misc::accurateDoubleToString(ratio, 2));
|
||||||
if (!h.is_seed() && h.has_metadata()) {
|
if (!h.is_seed() && h.has_metadata()) {
|
||||||
showPiecesDownloaded(true);
|
showPiecesDownloaded(true);
|
||||||
|
@ -220,7 +220,7 @@ void QBtSession::processBigRatios() {
|
|||||||
if (!h.is_valid()) continue;
|
if (!h.is_valid()) continue;
|
||||||
if (h.is_seed()) {
|
if (h.is_seed()) {
|
||||||
const QString hash = h.hash();
|
const QString hash = h.hash();
|
||||||
const qreal ratio = getRealRatio(hash);
|
const qreal ratio = getRealRatio(h);
|
||||||
qreal ratio_limit = TorrentPersistentData::getRatioLimit(hash);
|
qreal ratio_limit = TorrentPersistentData::getRatioLimit(hash);
|
||||||
if (ratio_limit == TorrentPersistentData::USE_GLOBAL_RATIO)
|
if (ratio_limit == TorrentPersistentData::USE_GLOBAL_RATIO)
|
||||||
ratio_limit = global_ratio_limit;
|
ratio_limit = global_ratio_limit;
|
||||||
@ -1556,8 +1556,7 @@ bool QBtSession::enableDHT(bool b) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal QBtSession::getRealRatio(const QString &hash) const {
|
qreal QBtSession::getRealRatio(QTorrentHandle h) const {
|
||||||
QTorrentHandle h = getTorrentHandle(hash);
|
|
||||||
if (!h.is_valid()) {
|
if (!h.is_valid()) {
|
||||||
return 0.;
|
return 0.;
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public:
|
|||||||
qreal getPayloadUploadRate() const;
|
qreal getPayloadUploadRate() const;
|
||||||
libtorrent::session_status getSessionStatus() const;
|
libtorrent::session_status getSessionStatus() const;
|
||||||
int getListenPort() const;
|
int getListenPort() const;
|
||||||
qreal getRealRatio(const QString& hash) const;
|
qreal getRealRatio(QTorrentHandle h) const;
|
||||||
QHash<QString, TrackerInfos> getTrackersInfo(const QString &hash) const;
|
QHash<QString, TrackerInfos> getTrackersInfo(const QString &hash) const;
|
||||||
bool hasActiveTorrents() const;
|
bool hasActiveTorrents() const;
|
||||||
bool hasDownloadingTorrents() const;
|
bool hasDownloadingTorrents() const;
|
||||||
|
@ -191,10 +191,10 @@ QVariant TorrentModelItem::data(int column, int role) const
|
|||||||
case TR_ETA: {
|
case TR_ETA: {
|
||||||
// XXX: Is this correct?
|
// XXX: Is this correct?
|
||||||
if (m_torrent.is_paused() || m_torrent.is_queued()) return MAX_ETA;
|
if (m_torrent.is_paused() || m_torrent.is_queued()) return MAX_ETA;
|
||||||
return QBtSession::instance()->getETA(m_torrent.hash());
|
return QBtSession::instance()->getETA(m_hash);
|
||||||
}
|
}
|
||||||
case TR_RATIO:
|
case TR_RATIO:
|
||||||
return QBtSession::instance()->getRealRatio(m_torrent.hash());
|
return QBtSession::instance()->getRealRatio(m_torrent);
|
||||||
case TR_LABEL:
|
case TR_LABEL:
|
||||||
return m_label;
|
return m_label;
|
||||||
case TR_ADD_DATE:
|
case TR_ADD_DATE:
|
||||||
|
@ -143,7 +143,7 @@ static JsonDict toJson(const QTorrentHandle& h)
|
|||||||
if (h.num_incomplete() > 0)
|
if (h.num_incomplete() > 0)
|
||||||
leechs += " ("+QString::number(h.num_incomplete())+")";
|
leechs += " ("+QString::number(h.num_incomplete())+")";
|
||||||
ret.add(KEY_TORRENT_LEECHS, leechs);
|
ret.add(KEY_TORRENT_LEECHS, leechs);
|
||||||
const qreal ratio = QBtSession::instance()->getRealRatio(h.hash());
|
const qreal ratio = QBtSession::instance()->getRealRatio(h);
|
||||||
ret.add(KEY_TORRENT_RATIO, (ratio > 100.) ? QString::fromUtf8("∞") : misc::accurateDoubleToString(ratio, 1));
|
ret.add(KEY_TORRENT_RATIO, (ratio > 100.) ? QString::fromUtf8("∞") : misc::accurateDoubleToString(ratio, 1));
|
||||||
QString eta;
|
QString eta;
|
||||||
QString state;
|
QString state;
|
||||||
@ -305,7 +305,7 @@ QString btjson::getPropertiesForTorrent(const QString& hash)
|
|||||||
elapsed_txt += " ("+tr("Seeded for %1", "e.g. Seeded for 3m10s").arg(misc::userFriendlyDuration(h.seeding_time()))+")";
|
elapsed_txt += " ("+tr("Seeded for %1", "e.g. Seeded for 3m10s").arg(misc::userFriendlyDuration(h.seeding_time()))+")";
|
||||||
data.add(KEY_PROP_TIME_ELAPSED, elapsed_txt);
|
data.add(KEY_PROP_TIME_ELAPSED, elapsed_txt);
|
||||||
data.add(KEY_PROP_CONNECT_COUNT, QString(QString::number(h.num_connections()) + " (" + tr("%1 max", "e.g. 10 max").arg(QString::number(h.connections_limit())) + ")"));
|
data.add(KEY_PROP_CONNECT_COUNT, QString(QString::number(h.num_connections()) + " (" + tr("%1 max", "e.g. 10 max").arg(QString::number(h.connections_limit())) + ")"));
|
||||||
const qreal ratio = QBtSession::instance()->getRealRatio(h.hash());
|
const qreal ratio = QBtSession::instance()->getRealRatio(h);
|
||||||
data.add(KEY_PROP_RATIO, ratio > 100. ? QString::fromUtf8("∞") : misc::accurateDoubleToString(ratio, 1));
|
data.add(KEY_PROP_RATIO, ratio > 100. ? QString::fromUtf8("∞") : misc::accurateDoubleToString(ratio, 1));
|
||||||
} catch(const std::exception& e) {
|
} catch(const std::exception& e) {
|
||||||
qWarning() << Q_FUNC_INFO << "Invalid torrent: " << e.what();
|
qWarning() << Q_FUNC_INFO << "Invalid torrent: " << e.what();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user