]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
shared_cache: pass key (K) by const ref in interface methods
authorSomnath Roy <somnath.roy@sandisk.com>
Mon, 30 Jun 2014 07:24:39 +0000 (00:24 -0700)
committerSomnath Roy <somnath.roy@sandisk.com>
Thu, 14 Aug 2014 22:28:30 +0000 (15:28 -0700)
Signed-off-by: Somnath Roy <somnath.roy@sandisk.com>
src/common/shared_cache.hpp

index 6e05a6880a30c7df9a3eaf4303c430c11f1e8608..ecb3abe01748bc8173ba76b916d373ec7c902add 100644 (file)
@@ -43,7 +43,7 @@ class SharedLRU {
     }
   }
 
-  void lru_remove(K key) {
+  void lru_remove(const K& key) {
     typename map<K, typename list<pair<K, VPtr> >::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<VPtr> *to_release) {
+  void lru_add(const K& key, const VPtr& val, list<VPtr> *to_release) {
     typename map<K, typename list<pair<K, VPtr> >::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<VPtr> to_release;
     {
@@ -145,7 +145,7 @@ public:
     return val;
   }
 
-  VPtr lookup(K key) {
+  VPtr lookup(const K& key) {
     VPtr val;
     list<VPtr> 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<VPtr> to_release;
     {