From: Kefu Chai Date: Sun, 26 Mar 2017 04:12:43 +0000 (+0800) Subject: mon/OSDMonitor: avoid search and lookup anti-pattern X-Git-Tag: v12.0.2~256^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=616e970ada85a0ec4b8fd76ef2efcc54f7040530;p=ceph.git mon/OSDMonitor: avoid search and lookup anti-pattern Signed-off-by: Kefu Chai --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index e01a5179e8b8..0aa20090eaf1 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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;