From 642054a983320b9d4ce80d6fa93e5221883a6b04 Mon Sep 17 00:00:00 2001 From: mmenke Date: Fri, 27 Feb 2015 18:54:31 -0800 Subject: [PATCH] Socket pools: Remove redundant seach for a group in GetLoadState. This was inspired by jank in the RDH method that calls the function, but will almost certainly have no effect on the jank. Also switch to using a range loop in GetLoadState as well. BUG=455952 Review URL: https://codereview.chromium.org/966943005 Cr-Commit-Position: refs/heads/master@{#318584} --- net/socket/client_socket_pool_base.cc | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc index d1ff627dd08b..4bc44f5999ea 100644 --- a/net/socket/client_socket_pool_base.cc +++ b/net/socket/client_socket_pool_base.cc @@ -562,22 +562,18 @@ LoadState ClientSocketPoolBaseHelper::GetLoadState( if (ContainsKey(pending_callback_map_, handle)) return LOAD_STATE_CONNECTING; - if (!ContainsKey(group_map_, group_name)) { - NOTREACHED() << "ClientSocketPool does not contain group: " << group_name - << " for handle: " << handle; - return LOAD_STATE_IDLE; - } - - // Can't use operator[] since it is non-const. - const Group& group = *group_map_.find(group_name)->second; + GroupMap::const_iterator group_it = group_map_.find(group_name); + // TODO(mmenke): Switch to DCHECK once sure this doesn't break anything. + // Added in M43. + CHECK(group_it != group_map_.end()); + const Group& group = *group_it->second; if (group.HasConnectJobForHandle(handle)) { - // Just return the state of the farthest along ConnectJob for the first + // Just return the state of the farthest along ConnectJob for the first // group.jobs().size() pending requests. LoadState max_state = LOAD_STATE_IDLE; - for (ConnectJobSet::const_iterator job_it = group.jobs().begin(); - job_it != group.jobs().end(); ++job_it) { - max_state = std::max(max_state, (*job_it)->GetLoadState()); + for (const auto& job : group.jobs()) { + max_state = std::max(max_state, job->GetLoadState()); } return max_state; } -- 2.11.4.GIT