]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: avoid search and lookup anti-pattern
authorKefu Chai <kchai@redhat.com>
Sun, 26 Mar 2017 04:12:43 +0000 (12:12 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 30 Mar 2017 12:21:18 +0000 (20:21 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mon/OSDMonitor.cc

index e01a5179e8b8a5daade5a937c72ccd99f4739bfb..0aa20090eaf10ae82a8afe57f77ad27bdccfa433 100644 (file)
@@ -9161,10 +9161,11 @@ int OSDMonitor::_prepare_remove_pool(int64_t pool, ostream *ss)
   if (r < 0)
     return r;
 
-  if (pending_inc.new_pools.count(pool)) {
+  auto new_pool = pending_inc.new_pools.find(pool);
+  if (new_pool != pending_inc.new_pools.end()) {
     // if there is a problem with the pending info, wait and retry
     // this op.
-    const auto& p = pending_inc.new_pools[pool];
+    const auto& p = new_pool->second;
     int r = _check_remove_pool(pool, p, ss);
     if (r < 0)
       return -EAGAIN;