From 19b4468c930085573ca0078e00a08182115da1bc Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 20 Jun 2025 15:31:56 +0800 Subject: [PATCH] osd/ECExtentCache: use default-generated comparison operators Replace manually implemented operator== and operator!= for Key with compiler-generated defaults. In C++20, comparison operators can be explicitly defaulted, and the generated behavior is identical to our hand-crafted implementation. This simplifies the code by letting the compiler handle operator generation automatically. Signed-off-by: Kefu Chai --- src/osd/ECExtentCache.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/osd/ECExtentCache.h b/src/osd/ECExtentCache.h index b4e06d6fddfd..0198cb331cda 100644 --- a/src/osd/ECExtentCache.h +++ b/src/osd/ECExtentCache.h @@ -111,14 +111,7 @@ class ECExtentCache { Key(uint64_t offset, const hobject_t &oid) : offset(offset), oid(oid) {}; - friend bool operator==(const Key &lhs, const Key &rhs) { - return lhs.offset == rhs.offset - && lhs.oid == rhs.oid; - } - - friend bool operator!=(const Key &lhs, const Key &rhs) { - return !(lhs == rhs); - } + bool operator==(const Key&) const = default; }; struct KeyHash { -- 2.47.3