mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 05:13:30 -07:00
Use std::vector instead of std::deque in QAlertDispatcher
As we never use {push,pop}_front std::vector works here perfectly. Also reserve memory for std::vector out of lock. This could be considered as an optimization, but in reality this is just using right container in right place. According to my measurements total speedup is under 0.2%.
This commit is contained in:
parent
d89d9c2f75
commit
333978f1ff
3 changed files with 13 additions and 8 deletions
|
@ -1649,7 +1649,7 @@ void QBtSession::saveFastResumeData() {
|
|||
} catch(libtorrent::invalid_handle&) {}
|
||||
}
|
||||
while (num_resume_data > 0) {
|
||||
std::deque<alert*> alerts;
|
||||
std::vector<alert*> alerts;
|
||||
m_alertDispatcher->getPendingAlerts(alerts, 30*1000);
|
||||
if (alerts.empty()) {
|
||||
std::cerr << " aborting with " << num_resume_data << " outstanding "
|
||||
|
@ -1657,7 +1657,7 @@ void QBtSession::saveFastResumeData() {
|
|||
break;
|
||||
}
|
||||
|
||||
for (std::deque<alert*>::const_iterator i = alerts.begin(), end = alerts.end(); i != end; ++i)
|
||||
for (std::vector<alert*>::const_iterator i = alerts.begin(), end = alerts.end(); i != end; ++i)
|
||||
{
|
||||
alert const* a = *i;
|
||||
// Saving fastresume data can fail
|
||||
|
@ -2147,7 +2147,7 @@ void QBtSession::sendNotificationEmail(const QTorrentHandle &h) {
|
|||
// Read alerts sent by the Bittorrent session
|
||||
void QBtSession::readAlerts() {
|
||||
|
||||
typedef std::deque<alert*> alerts_t;
|
||||
typedef std::vector<alert*> alerts_t;
|
||||
alerts_t alerts;
|
||||
m_alertDispatcher->getPendingAlertsNoWait(alerts);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue