From 616e970ada85a0ec4b8fd76ef2efcc54f7040530 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 26 Mar 2017 12:12:43 +0800 Subject: [PATCH] mon/OSDMonitor: avoid search and lookup anti-pattern Signed-off-by: Kefu Chai --- src/mon/OSDMonitor.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index e01a5179e8b8a..0aa20090eaf10 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; -- 2.47.3