]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds/SessionMap.h: remove unneeded use of count 11358/head
authorMichal Jarzabek <stiopa@gmail.com>
Thu, 6 Oct 2016 20:30:43 +0000 (21:30 +0100)
committerMichal Jarzabek <stiopa@gmail.com>
Sun, 9 Oct 2016 11:49:23 +0000 (12:49 +0100)
Signed-off-by: Michal Jarzabek <stiopa@gmail.com>
src/mds/SessionMap.h

index ec28e4483bf9e1d6bbdb0d1144fe73fa9ea216e3..55242509b5955237b8dd3f11fa0a15dc20e7b069 100644 (file)
@@ -404,8 +404,9 @@ public:
 
   Session* get_or_add_session(const entity_inst_t& i) {
     Session *s;
-    if (session_map.count(i.name)) {
-      s = session_map[i.name];
+    auto session_map_entry = session_map.find(i.name);
+    if (session_map_entry != session_map.end()) {
+      s = session_map_entry->second;
     } else {
       s = session_map[i.name] = new Session;
       s->info.inst = i;
@@ -512,9 +513,9 @@ public:
     return session_map.count(w);
   }
   Session* get_session(entity_name_t w) {
-    if (session_map.count(w))
-      return session_map[w];
-    return 0;
+    auto session_map_entry = session_map.find(w);
+    return (session_map_entry != session_map.end() ?
+           session_map_entry-> second : nullptr);
   }
   const Session* get_session(entity_name_t w) const {
     ceph::unordered_map<entity_name_t, Session*>::const_iterator p = session_map.find(w);
@@ -530,9 +531,10 @@ public:
   void touch_session(Session *session);
 
   Session *get_oldest_session(int state) {
-    if (by_state.count(state) == 0 || by_state[state]->empty())
+    auto by_state_entry = by_state.find(state);
+    if (by_state_entry == by_state.end() || by_state_entry->second->empty())
       return 0;
-    return by_state[state]->front();
+    return by_state_entry->second->front();
   }
 
   void dump();