From: Somnath Roy Date: Mon, 30 Jun 2014 07:24:39 +0000 (-0700) Subject: shared_cache: pass key (K) by const ref in interface methods X-Git-Tag: v0.85~37^2~4 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b04d84db8c1060cf7489abfaa55253dd2125ba66;p=ceph.git shared_cache: pass key (K) by const ref in interface methods Signed-off-by: Somnath Roy --- diff --git a/src/common/shared_cache.hpp b/src/common/shared_cache.hpp index 6e05a6880a30c..ecb3abe01748b 100644 --- a/src/common/shared_cache.hpp +++ b/src/common/shared_cache.hpp @@ -43,7 +43,7 @@ class SharedLRU { } } - void lru_remove(K key) { + void lru_remove(const K& key) { typename map >::iterator>::iterator i = contents.find(key); if (i == contents.end()) @@ -53,7 +53,7 @@ class SharedLRU { contents.erase(i); } - void lru_add(K key, VPtr val, list *to_release) { + void lru_add(const K& key, const VPtr& val, list *to_release) { typename map >::iterator>::iterator i = contents.find(key); if (i != contents.end()) { @@ -66,7 +66,7 @@ class SharedLRU { } } - void remove(K key) { + void remove(const K& key) { Mutex::Locker l(lock); weak_refs.erase(key); cond.Signal(); @@ -93,7 +93,7 @@ public: assert(weak_refs.empty()); } - void clear(K key) { + void clear(const K& key) { VPtr val; // release any ref we have after we drop the lock { Mutex::Locker l(lock); @@ -119,7 +119,7 @@ public: return weak_refs.begin()->first; } - VPtr lower_bound(K key) { + VPtr lower_bound(const K& key) { VPtr val; list to_release; { @@ -145,7 +145,7 @@ public: return val; } - VPtr lookup(K key) { + VPtr lookup(const K& key) { VPtr val; list to_release; { @@ -181,7 +181,7 @@ public: * map, false otherwise * @return A reference to the map's value for the given key */ - VPtr add(K key, V *value, bool *existed = NULL) { + VPtr add(const K& key, V *value, bool *existed = NULL) { VPtr val(value, Cleanup(this, key)); list to_release; {