mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-11 16:49:22 +00:00
Simplify updating queue entries
The erase/insert pattern can be replaced by a single method that updates an existing entry's timer, or inserting if it doesn't exist. This has much less impact than the libtorrent change it's based on, but might as well be consistent.
This commit is contained in:
@@ -74,6 +74,10 @@ public:
|
||||
base_type::pop_back();
|
||||
}
|
||||
|
||||
void update() {
|
||||
std::make_heap(begin(), end(), m_compare);
|
||||
}
|
||||
|
||||
void push(const value_type& value) {
|
||||
base_type::push_back(value);
|
||||
std::push_heap(begin(), end(), m_compare);
|
||||
@@ -95,12 +99,8 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
// Removes 'itr' from the queue. This assumes 'itr' has been
|
||||
// modified such that it has a higher priority than any other
|
||||
// element in the queue.
|
||||
// Removes 'itr' from the queue.
|
||||
void erase(iterator itr) {
|
||||
// std::push_heap(begin(), ++itr, m_compare);
|
||||
// pop();
|
||||
base_type::erase(itr);
|
||||
std::make_heap(begin(), end(), m_compare);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user