Skip to content

Commit

Permalink
Session::PriorityQueue: minor simplification
Browse files Browse the repository at this point in the history
GitOrigin-RevId: f0baab28bb95afef247e4ad0c291222be6d105c5
  • Loading branch information
arseny30 committed Aug 18, 2020
1 parent c1252ad commit 89fad4f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions td/telegram/net/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ void Session::PriorityQueue::push(NetQueryPtr query) {
}

NetQueryPtr Session::PriorityQueue::pop() {
auto it = queries_.rbegin();
CHECK(it != queries_.rend());
CHECK(!empty());
auto it = queries_.begin();
auto res = it->second.pop();
if (it->second.empty()) {
queries_.erase(it->first);
queries_.erase(it);
}
return res;
}
Expand Down
3 changes: 2 additions & 1 deletion td/telegram/net/Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include <array>
#include <deque>
#include <functional>
#include <map>
#include <memory>
#include <unordered_map>
Expand Down Expand Up @@ -132,7 +133,7 @@ class Session final
bool empty() const;

private:
std::map<int8, VectorQueue<NetQueryPtr>> queries_;
std::map<int8, VectorQueue<NetQueryPtr>, std::greater<>> queries_;
};
PriorityQueue pending_queries_;
std::map<uint64, Query> sent_queries_;
Expand Down

0 comments on commit 89fad4f

Please sign in to comment.