diff options
author | Max Kellermann <max.kellermann@ionos.com> | 2024-10-08 12:41:45 +0200 |
---|---|---|
committer | Max Kellermann <max.kellermann@ionos.com> | 2024-10-09 23:15:15 +0200 |
commit | 6597d773611b6e74cacad5f2645ab6a8da99c634 (patch) | |
tree | 65dc1999c86746bdedc4be6ff329108505ecadea /src/msg/async/ProtocolV1.cc | |
parent | msg/async/ProtocolV[12]: reverse the std::map sort order (diff) | |
download | ceph-6597d773611b6e74cacad5f2645ab6a8da99c634.tar.xz ceph-6597d773611b6e74cacad5f2645ab6a8da99c634.zip |
msg/async/ProtocolV2: eliminate redundant std::map lookups
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Diffstat (limited to 'src/msg/async/ProtocolV1.cc')
-rw-r--r-- | src/msg/async/ProtocolV1.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/msg/async/ProtocolV1.cc b/src/msg/async/ProtocolV1.cc index 1a6a2e6e688..cecf81498c7 100644 --- a/src/msg/async/ProtocolV1.cc +++ b/src/msg/async/ProtocolV1.cc @@ -1219,10 +1219,11 @@ void ProtocolV1::requeue_sent() { uint64_t ProtocolV1::discard_requeued_up_to(uint64_t out_seq, uint64_t seq) { ldout(cct, 10) << __func__ << " " << seq << dendl; std::lock_guard<std::mutex> l(connection->write_lock); - if (out_q.count(CEPH_MSG_PRIO_HIGHEST) == 0) { + const auto it = out_q.find(CEPH_MSG_PRIO_HIGHEST); + if (it == out_q.end()) { return seq; } - auto &rq = out_q[CEPH_MSG_PRIO_HIGHEST]; + auto &rq = it->second; uint64_t count = out_seq; while (!rq.empty()) { Message* const m = rq.front().m; @@ -1234,7 +1235,7 @@ uint64_t ProtocolV1::discard_requeued_up_to(uint64_t out_seq, uint64_t seq) { rq.pop_front(); count++; } - if (rq.empty()) out_q.erase(CEPH_MSG_PRIO_HIGHEST); + if (rq.empty()) out_q.erase(it); return count; } @@ -1325,8 +1326,7 @@ void ProtocolV1::reset_recv_state() ProtocolV1::out_q_entry_t ProtocolV1::_get_next_outgoing() { out_q_entry_t out_entry; - if (!out_q.empty()) { - const auto it = out_q.begin(); + if (const auto it = out_q.begin(); it != out_q.end()) { ceph_assert(!it->second.empty()); const auto p = it->second.begin(); out_entry = *p; |