From e710e5ade7080a030f987f740d05668baade56a1 Mon Sep 17 00:00:00 2001 From: Michal Jarzabek Date: Sat, 22 Oct 2016 17:26:29 +0100 Subject: [PATCH] mds/SnapRealm: remove unneeded use of count Signed-off-by: Michal Jarzabek --- src/mds/SnapRealm.cc | 7 ++++--- src/mds/SnapRealm.h | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/mds/SnapRealm.cc b/src/mds/SnapRealm.cc index d8a860e36adab..3c9251bf80add 100644 --- a/src/mds/SnapRealm.cc +++ b/src/mds/SnapRealm.cc @@ -332,11 +332,12 @@ void SnapRealm::get_snap_info(map& 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::iterator p = srnode.past_parents.lower_bound(snapid); diff --git a/src/mds/SnapRealm.h b/src/mds/SnapRealm.h index 390398787fa70..7be066788c2e4 100644 --- a/src/mds/SnapRealm.h +++ b/src/mds/SnapRealm.h @@ -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; - 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).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(); -- 2.39.5