From: Matan Breizman Date: Thu, 9 Nov 2023 16:51:20 +0000 (+0000) Subject: crimson/common/shared_lru: introduce cached_key_lower_bound() X-Git-Tag: v19.0.0~4^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d2c5c04f36d040d69df0f76679be9802eee95c8e;p=ceph.git crimson/common/shared_lru: introduce cached_key_lower_bound() Signed-off-by: Matan Breizman --- diff --git a/src/crimson/common/shared_lru.h b/src/crimson/common/shared_lru.h index 186f02a614c9..92d99d332c44 100644 --- a/src/crimson/common/shared_lru.h +++ b/src/crimson/common/shared_lru.h @@ -83,6 +83,7 @@ public: cache.clear(); } shared_ptr_t find(const K& key); + K cached_key_lower_bound(); // return the last element that is not greater than key shared_ptr_t lower_bound(const K& key); // return the first element that is greater than key @@ -146,6 +147,15 @@ SharedLRU::find(const K& key) return val; } +template +K SharedLRU::cached_key_lower_bound() +{ + if (weak_refs.empty()) { + return {}; + } + return weak_refs.begin()->first; +} + template typename SharedLRU::shared_ptr_t SharedLRU::lower_bound(const K& key)