From: Samuel Just Date: Thu, 15 Jan 2015 05:09:45 +0000 (-0800) Subject: shared_cache: reduce duplication between get_next's X-Git-Tag: v0.93~163^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=37dc4238fec4dd42e27a9a900b574a4a1efda452;p=ceph.git shared_cache: reduce duplication between get_next's Signed-off-by: Samuel Just --- diff --git a/src/common/shared_cache.hpp b/src/common/shared_cache.hpp index 7bdf03ee24e3..aaa47f04f371 100644 --- a/src/common/shared_cache.hpp +++ b/src/common/shared_cache.hpp @@ -227,25 +227,14 @@ public: return true; } bool get_next(const K &key, pair *next) { - pair r; - { - Mutex::Locker l(lock); - VPtr next_val; - typename map >::iterator i = weak_refs.upper_bound(key); - - while (i != weak_refs.end() && - !(next_val = i->second.first.lock())) - ++i; - - if (i == weak_refs.end()) - return false; - - if (next) - r = make_pair(i->first, *next_val); - } - if (next) - *next = r; - return true; + pair r; + bool found = get_next(key, &r); + if (!found || !next) + return found; + next->first = r.first; + assert(r.second); + next->second = *(r.second); + return found; } VPtr lookup(const K& key) {