mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-06 05:01:25 -07:00
Optimize conversion of time points from libtorrent to Qt clocks
Obtain current date time of Qt and libtorrent clocks only once for processing entire current libtorrent alerts bunch. PR #21764.
This commit is contained in:
parent
051d7137ea
commit
75d1ac8889
3 changed files with 26 additions and 11 deletions
|
@ -5504,6 +5504,11 @@ void SessionImpl::setTorrentContentLayout(const TorrentContentLayout value)
|
|||
// Read alerts sent by libtorrent session
|
||||
void SessionImpl::readAlerts()
|
||||
{
|
||||
// cache current datetime of Qt and libtorrent clocks in order
|
||||
// to optimize conversion of time points from lt to Qt clocks
|
||||
m_ltNow = lt::clock_type::now();
|
||||
m_qNow = QDateTime::currentDateTime();
|
||||
|
||||
const std::vector<lt::alert *> alerts = getPendingAlerts();
|
||||
|
||||
Q_ASSERT(m_loadedTorrents.isEmpty());
|
||||
|
@ -6373,3 +6378,9 @@ void SessionImpl::handleRemovedTorrent(const TorrentID &torrentID, const QString
|
|||
|
||||
m_removingTorrents.erase(removingTorrentDataIter);
|
||||
}
|
||||
|
||||
QDateTime SessionImpl::fromLTTimePoint32(const libtorrent::time_point32 &timePoint) const
|
||||
{
|
||||
const auto secsSinceNow = lt::duration_cast<lt::seconds>(timePoint - m_ltNow + lt::milliseconds(500)).count();
|
||||
return m_qNow.addSecs(secsSinceNow);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue