]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds/SnapRealm: remove unneeded use of count 11609/head
authorMichal Jarzabek <stiopa@gmail.com>
Sat, 22 Oct 2016 16:26:29 +0000 (17:26 +0100)
committerMichal Jarzabek <stiopa@gmail.com>
Sat, 22 Oct 2016 16:27:58 +0000 (17:27 +0100)
Signed-off-by: Michal Jarzabek <stiopa@gmail.com>
src/mds/SnapRealm.cc
src/mds/SnapRealm.h

index d8a860e36adabafe6d398d31ca2788dd905fd7fc..3c9251bf80addf44ed87f32f1a19598055f8ddcb 100644 (file)
@@ -332,11 +332,12 @@ void SnapRealm::get_snap_info(map<snapid_t,SnapInfo*>& infomap, snapid_t first,
 
 const string& SnapRealm::get_snapname(snapid_t snapid, inodeno_t atino)
 {
-  if (srnode.snaps.count(snapid)) {
+  auto srnode_snaps_entry = srnode.snaps.find(snapid);
+  if (srnode_snaps_entry != srnode.snaps.end()) {
     if (atino == inode->ino())
-      return srnode.snaps[snapid].name;
+      return srnode_snaps_entry->second.name;
     else
-      return srnode.snaps[snapid].get_long_name();
+      return srnode_snaps_entry->second.get_long_name();
   }
 
   map<snapid_t,snaplink_t>::iterator p = srnode.past_parents.lower_bound(snapid);
index 390398787fa70408b14cf8fb0f37ed1913b10959..7be066788c2e419d332d7299e36c88d505e59d33 100644 (file)
@@ -145,9 +145,11 @@ struct SnapRealm {
   void join(SnapRealm *child);
 
   void add_cap(client_t client, Capability *cap) {
-    if (client_caps.count(client) == 0)
-      client_caps[client] = new xlist<Capability*>;
-    client_caps[client]->push_back(&cap->item_snaprealm_caps);
+    auto client_caps_entry = client_caps.find(client);
+    if (client_caps_entry == client_caps.end())
+      client_caps_entry = client_caps.emplace(client,
+                                             new xlist<Capability*>).first;
+    client_caps_entry->second->push_back(&cap->item_snaprealm_caps);
   }
   void remove_cap(client_t client, Capability *cap) {
     cap->item_snaprealm_caps.remove_myself();