Commit 49418e62 authored by vmpstr's avatar vmpstr Committed by Commit bot

Use proper pair type in range-based for map iterations.

Since map<Key, Value>::value_type is std::pair<const Key, Value>, we
need to ensure that we use this type to avoid an extra copy/temporary
creation. This patch does this by explicitly using value_type where
it is clear what the type is, and adding const to the key where it's not.

Review URL: https://codereview.chromium.org/853533002

Cr-Commit-Position: refs/heads/master@{#311524}
parent 60fa9805
...@@ -333,7 +333,7 @@ void ExpireHistoryTest::EnsureURLInfoGone(const URLRow& row, bool expired) { ...@@ -333,7 +333,7 @@ void ExpireHistoryTest::EnsureURLInfoGone(const URLRow& row, bool expired) {
// EXPECT_FALSE(HasThumbnail(row.id())); // EXPECT_FALSE(HasThumbnail(row.id()));
bool found_delete_notification = false; bool found_delete_notification = false;
for (const std::pair<bool, URLRows>& pair : urls_deleted_notifications_) { for (const auto& pair : urls_deleted_notifications_) {
EXPECT_EQ(expired, pair.first); EXPECT_EQ(expired, pair.first);
const history::URLRows& rows(pair.second); const history::URLRows& rows(pair.second);
history::URLRows::const_iterator it_row = std::find_if( history::URLRows::const_iterator it_row = std::find_if(
......
...@@ -315,7 +315,7 @@ SupervisedUserURLFilter::GetFilteringBehaviorForURL( ...@@ -315,7 +315,7 @@ SupervisedUserURLFilter::GetFilteringBehaviorForURL(
// Look for patterns matching the hostname, with a value that is different // Look for patterns matching the hostname, with a value that is different
// from the default (a value of true in the map meaning allowed). // from the default (a value of true in the map meaning allowed).
for (const std::pair<std::string, bool>& host_entry : host_map_) { for (const auto& host_entry : host_map_) {
if ((host_entry.second == (default_behavior_ == BLOCK)) && if ((host_entry.second == (default_behavior_ == BLOCK)) &&
HostMatchesPattern(host, host_entry.first)) { HostMatchesPattern(host, host_entry.first)) {
return host_entry.second ? ALLOW : BLOCK; return host_entry.second ? ALLOW : BLOCK;
......
...@@ -236,7 +236,7 @@ scoped_ptr<base::ListValue> HidDeviceManager::CreateApiDeviceList( ...@@ -236,7 +236,7 @@ scoped_ptr<base::ListValue> HidDeviceManager::CreateApiDeviceList(
DCHECK(hid_service); DCHECK(hid_service);
scoped_ptr<base::ListValue> api_devices(new base::ListValue()); scoped_ptr<base::ListValue> api_devices(new base::ListValue());
for (const std::pair<int, HidDeviceId>& map_entry : device_ids_) { for (const ResourceIdToDeviceIdMap::value_type& map_entry : device_ids_) {
int resource_id = map_entry.first; int resource_id = map_entry.first;
const HidDeviceId& device_id = map_entry.second; const HidDeviceId& device_id = map_entry.second;
......
...@@ -1146,7 +1146,7 @@ void QuicStreamFactory::InitializeCachedStateInCryptoConfig( ...@@ -1146,7 +1146,7 @@ void QuicStreamFactory::InitializeCachedStateInCryptoConfig(
if (http_server_properties_) { if (http_server_properties_) {
if (quic_supported_servers_at_startup_.empty()) { if (quic_supported_servers_at_startup_.empty()) {
for (const std::pair<net::HostPortPair, net::AlternateProtocolInfo>& for (const std::pair<const net::HostPortPair, net::AlternateProtocolInfo>&
key_value : http_server_properties_->alternate_protocol_map()) { key_value : http_server_properties_->alternate_protocol_map()) {
if (key_value.second.protocol == QUIC) { if (key_value.second.protocol == QUIC) {
quic_supported_servers_at_startup_.insert(key_value.first); quic_supported_servers_at_startup_.insert(key_value.first);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment