From: Kefu Chai Date: Sun, 7 Mar 2021 02:47:20 +0000 (+0800) Subject: crimson/osd: use transparent comparator X-Git-Tag: v17.1.0~2713^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b1dbf306d287fbaab248b17e06d14010776e71fa;p=ceph.git crimson/osd: use transparent comparator for better readability Signed-off-by: Kefu Chai --- diff --git a/src/crimson/osd/watch.cc b/src/crimson/osd/watch.cc index a69ea8d728af..789d0fd346b9 100644 --- a/src/crimson/osd/watch.cc +++ b/src/crimson/osd/watch.cc @@ -18,13 +18,6 @@ namespace { namespace crimson::osd { -bool Watch::NotifyCmp::operator()(NotifyRef lhs, NotifyRef rhs) const -{ - ceph_assert(lhs); - ceph_assert(rhs); - return lhs->get_id() < rhs->get_id(); -} - seastar::future<> Watch::connect(crimson::net::ConnectionRef conn, bool) { if (this->conn == conn) { @@ -110,11 +103,7 @@ seastar::future<> Watch::remove(const bool send_disconnect) void Watch::cancel_notify(const uint64_t notify_id) { logger().info("{} notify_id={}", __func__, notify_id); - const auto it = std::find_if( - std::begin(in_progress_notifies), std::end(in_progress_notifies), - [notify_id] (const auto& notify) { - return notify->ninfo.notify_id == notify_id; - }); + const auto it = in_progress_notifies.find(notify_id); assert(it != std::end(in_progress_notifies)); in_progress_notifies.erase(it); } diff --git a/src/crimson/osd/watch.h b/src/crimson/osd/watch.h index f787b34e299e..3632f427280c 100644 --- a/src/crimson/osd/watch.h +++ b/src/crimson/osd/watch.h @@ -32,10 +32,7 @@ class Watch : public seastar::enable_shared_from_this { // used by create(). struct private_ctag_t{}; - struct NotifyCmp { - inline bool operator()(NotifyRef lhs, NotifyRef rhs) const; - }; - std::set in_progress_notifies; + std::set> in_progress_notifies; crimson::net::ConnectionRef conn; crimson::osd::ObjectContextRef obc; @@ -145,6 +142,21 @@ class Notify { // used by create_n_propagate factory. struct private_ctag_t{}; + using ptr_t = seastar::shared_ptr; + friend bool operator<(const ptr_t& lhs, const ptr_t& rhs) { + assert(lhs); + assert(rhs); + return lhs->get_id() < rhs->get_id(); + } + friend bool operator<(const ptr_t& ptr, const uint64_t id) { + assert(ptr); + return ptr->get_id() < id; + } + friend bool operator<(const uint64_t id, const ptr_t& ptr) { + assert(ptr); + return id < ptr->get_id(); + } + friend Watch; public: