summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsbell <jsbell@chromium.org>2015-11-20 11:07:39 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-20 19:08:34 +0000
commitdd1a3ea18cc2301d7d6a6a7b5058216b4883bd3a (patch)
treecd6f6b90430f2a3b88399815ccb61dee3e2c4040
parentf440aa1a1e31c13ffc981612f50f330e944e2bb4 (diff)
downloadchromium_src-dd1a3ea18cc2301d7d6a6a7b5058216b4883bd3a.zip
chromium_src-dd1a3ea18cc2301d7d6a6a7b5058216b4883bd3a.tar.gz
chromium_src-dd1a3ea18cc2301d7d6a6a7b5058216b4883bd3a.tar.bz2
Reland of Use std::tie() for operator< in components/ (patchset #1 id:1 of https://codereview.chromium.org/1456263005/ )
Reason for revert: Did not resolve perf regression, so re-landing. Original issue's description: > Revert of Use std::tie() for operator< in components/ (patchset #1 id:1 of https://codereview.chromium.org/1447153002/ ) > > Reason for revert: > Perf regression? Shouldn't be, but let's check. https://crbug.com/558616 > > Original issue's description: > > Use std::tie() for operator< in components/ > > > > Simplify the code for operator< when comparing multiple members using > > a common std::tie idiom. > > > > BUG=555171 > > R=thakis@chromium.org,vabr@chromium.org,jochen@chromium.org > > > > Committed: https://crrev.com/4afb256b17b1c9a716a031205f48f4648768c308 > > Cr-Commit-Position: refs/heads/master@{#360367} > > TBR=jochen@chromium.org,thakis@chromium.org,vabr@chromium.org > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=555171 > > Committed: https://crrev.com/0a0c449a5af92bdca0e37d539617e9d4dffae220 > Cr-Commit-Position: refs/heads/master@{#360707} TBR=jochen@chromium.org,thakis@chromium.org,vabr@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=555171 Review URL: https://codereview.chromium.org/1459973005 Cr-Commit-Position: refs/heads/master@{#360868}
-rw-r--r--components/autofill/core/common/form_data.cc14
-rw-r--r--components/autofill/core/common/form_field_data.cc30
-rw-r--r--components/autofill/core/common/password_form_fill_data.cc9
-rw-r--r--components/content_settings/core/browser/content_settings_origin_identifier_value_map.cc14
-rw-r--r--components/guest_view/browser/guest_view_manager.cc8
-rw-r--r--components/mus/ws/ids.h8
-rw-r--r--components/policy/core/common/policy_namespace.cc6
-rw-r--r--components/url_matcher/string_pattern.cc5
8 files changed, 39 insertions, 55 deletions
diff --git a/components/autofill/core/common/form_data.cc b/components/autofill/core/common/form_data.cc
index aaa8178f..3d68639 100644
--- a/components/autofill/core/common/form_data.cc
+++ b/components/autofill/core/common/form_data.cc
@@ -4,6 +4,8 @@
#include "components/autofill/core/common/form_data.h"
+#include <tuple>
+
#include "base/base64.h"
#include "base/pickle.h"
#include "base/strings/string_util.h"
@@ -86,15 +88,9 @@ bool FormData::SameFormAs(const FormData& form) const {
}
bool FormData::operator<(const FormData& form) const {
- if (name != form.name)
- return name < form.name;
- if (origin != form.origin)
- return origin < form.origin;
- if (action != form.action)
- return action < form.action;
- if (is_form_tag != form.is_form_tag)
- return is_form_tag < form.is_form_tag;
- return fields < form.fields;
+ return std::tie(name, origin, action, is_form_tag, fields) <
+ std::tie(form.name, form.origin, form.action, form.is_form_tag,
+ form.fields);
}
std::ostream& operator<<(std::ostream& os, const FormData& form) {
diff --git a/components/autofill/core/common/form_field_data.cc b/components/autofill/core/common/form_field_data.cc
index 1ae3446..54db610 100644
--- a/components/autofill/core/common/form_field_data.cc
+++ b/components/autofill/core/common/form_field_data.cc
@@ -4,6 +4,8 @@
#include "components/autofill/core/common/form_field_data.h"
+#include <tuple>
+
#include "base/pickle.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -117,29 +119,15 @@ bool FormFieldData::SameFieldAs(const FormFieldData& field) const {
bool FormFieldData::operator<(const FormFieldData& field) const {
// Like operator==, this ignores the value.
- if (label < field.label) return true;
- if (label > field.label) return false;
- if (name < field.name) return true;
- if (name > field.name) return false;
- if (form_control_type < field.form_control_type) return true;
- if (form_control_type > field.form_control_type) return false;
- if (autocomplete_attribute < field.autocomplete_attribute) return true;
- if (autocomplete_attribute > field.autocomplete_attribute) return false;
- if (max_length < field.max_length) return true;
- if (max_length > field.max_length) return false;
// Skip |is_checked| and |is_autofilled| as in SameFieldAs.
- if (is_checkable < field.is_checkable) return true;
- if (is_checkable > field.is_checkable) return false;
- if (is_focusable < field.is_focusable) return true;
- if (is_focusable > field.is_focusable) return false;
- if (should_autocomplete < field.should_autocomplete) return true;
- if (should_autocomplete > field.should_autocomplete) return false;
- if (role < field.role) return true;
- if (role > field.role) return false;
- if (text_direction < field.text_direction) return true;
- if (text_direction > field.text_direction) return false;
// See operator== above for why we don't check option_values/contents.
- return false;
+ return std::tie(label, name, form_control_type, autocomplete_attribute,
+ max_length, is_checkable, is_focusable, should_autocomplete,
+ role, text_direction) <
+ std::tie(field.label, field.name, field.form_control_type,
+ field.autocomplete_attribute, field.max_length,
+ field.is_checkable, field.is_focusable,
+ field.should_autocomplete, field.role, field.text_direction);
}
void SerializeFormFieldData(const FormFieldData& field_data,
diff --git a/components/autofill/core/common/password_form_fill_data.cc b/components/autofill/core/common/password_form_fill_data.cc
index 148b5c2..1c35ba2 100644
--- a/components/autofill/core/common/password_form_fill_data.cc
+++ b/components/autofill/core/common/password_form_fill_data.cc
@@ -4,6 +4,8 @@
#include "components/autofill/core/common/password_form_fill_data.h"
+#include <tuple>
+
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/common/form_field_data.h"
@@ -15,11 +17,8 @@ UsernamesCollectionKey::~UsernamesCollectionKey() {}
bool UsernamesCollectionKey::operator<(
const UsernamesCollectionKey& other) const {
- if (username != other.username)
- return username < other.username;
- if (password != other.password)
- return password < other.password;
- return realm < other.realm;
+ return std::tie(username, password, realm) <
+ std::tie(other.username, other.password, other.realm);
}
PasswordFormFillData::PasswordFormFillData()
diff --git a/components/content_settings/core/browser/content_settings_origin_identifier_value_map.cc b/components/content_settings/core/browser/content_settings_origin_identifier_value_map.cc
index d51e624..0c3ab90 100644
--- a/components/content_settings/core/browser/content_settings_origin_identifier_value_map.cc
+++ b/components/content_settings/core/browser/content_settings_origin_identifier_value_map.cc
@@ -4,6 +4,8 @@
#include "components/content_settings/core/browser/content_settings_origin_identifier_value_map.h"
+#include <tuple>
+
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -61,9 +63,8 @@ OriginIdentifierValueMap::EntryMapKey::EntryMapKey(
bool OriginIdentifierValueMap::EntryMapKey::operator<(
const OriginIdentifierValueMap::EntryMapKey& other) const {
- if (content_type != other.content_type)
- return content_type < other.content_type;
- return (resource_identifier < other.resource_identifier);
+ return std::tie(content_type, resource_identifier) <
+ std::tie(other.content_type, other.resource_identifier);
}
OriginIdentifierValueMap::PatternPair::PatternPair(
@@ -78,11 +79,8 @@ bool OriginIdentifierValueMap::PatternPair::operator<(
// Note that this operator is the other way around than
// |ContentSettingsPattern::operator<|. It sorts patterns with higher
// precedence first.
- if (primary_pattern > other.primary_pattern)
- return true;
- else if (other.primary_pattern > primary_pattern)
- return false;
- return (secondary_pattern > other.secondary_pattern);
+ return std::tie(primary_pattern, secondary_pattern) >
+ std::tie(other.primary_pattern, other.secondary_pattern);
}
RuleIterator* OriginIdentifierValueMap::GetRuleIterator(
diff --git a/components/guest_view/browser/guest_view_manager.cc b/components/guest_view/browser/guest_view_manager.cc
index 4c86e9d..c93f953 100644
--- a/components/guest_view/browser/guest_view_manager.cc
+++ b/components/guest_view/browser/guest_view_manager.cc
@@ -4,6 +4,8 @@
#include "components/guest_view/browser/guest_view_manager.h"
+#include <tuple>
+
#include "base/macros.h"
#include "base/strings/stringprintf.h"
#include "components/guest_view/browser/guest_view_base.h"
@@ -476,10 +478,8 @@ GuestViewManager::ElementInstanceKey::ElementInstanceKey(
bool GuestViewManager::ElementInstanceKey::operator<(
const GuestViewManager::ElementInstanceKey& other) const {
- if (embedder_process_id != other.embedder_process_id)
- return embedder_process_id < other.embedder_process_id;
-
- return element_instance_id < other.element_instance_id;
+ return std::tie(embedder_process_id, element_instance_id) <
+ std::tie(other.embedder_process_id, other.element_instance_id);
}
bool GuestViewManager::ElementInstanceKey::operator==(
diff --git a/components/mus/ws/ids.h b/components/mus/ws/ids.h
index 3c814d0..8ae41c9 100644
--- a/components/mus/ws/ids.h
+++ b/components/mus/ws/ids.h
@@ -5,6 +5,8 @@
#ifndef COMPONENTS_MUS_WS_IDS_H_
#define COMPONENTS_MUS_WS_IDS_H_
+#include <tuple>
+
#include "components/mus/common/types.h"
#include "components/mus/common/util.h"
@@ -29,10 +31,8 @@ struct WindowId {
bool operator!=(const WindowId& other) const { return !(*this == other); }
bool operator<(const WindowId& other) const {
- if (connection_id == other.connection_id)
- return window_id < other.window_id;
-
- return connection_id < other.connection_id;
+ return std::tie(connection_id, window_id) <
+ std::tie(other.connection_id, other.window_id);
}
ConnectionSpecificId connection_id;
diff --git a/components/policy/core/common/policy_namespace.cc b/components/policy/core/common/policy_namespace.cc
index 0fac9ca..33a9992 100644
--- a/components/policy/core/common/policy_namespace.cc
+++ b/components/policy/core/common/policy_namespace.cc
@@ -4,6 +4,8 @@
#include "components/policy/core/common/policy_namespace.h"
+#include <tuple>
+
namespace policy {
PolicyNamespace::PolicyNamespace() {}
@@ -26,8 +28,8 @@ PolicyNamespace& PolicyNamespace::operator=(const PolicyNamespace& other) {
}
bool PolicyNamespace::operator<(const PolicyNamespace& other) const {
- return domain < other.domain ||
- (domain == other.domain && component_id < other.component_id);
+ return std::tie(domain, component_id) <
+ std::tie(other.domain, other.component_id);
}
bool PolicyNamespace::operator==(const PolicyNamespace& other) const {
diff --git a/components/url_matcher/string_pattern.cc b/components/url_matcher/string_pattern.cc
index d103bce..a4b87bc 100644
--- a/components/url_matcher/string_pattern.cc
+++ b/components/url_matcher/string_pattern.cc
@@ -4,6 +4,8 @@
#include "components/url_matcher/string_pattern.h"
+#include <tuple>
+
namespace url_matcher {
StringPattern::StringPattern(const std::string& pattern,
@@ -13,8 +15,7 @@ StringPattern::StringPattern(const std::string& pattern,
StringPattern::~StringPattern() {}
bool StringPattern::operator<(const StringPattern& rhs) const {
- if (id_ != rhs.id_) return id_ < rhs.id_;
- return pattern_ < rhs.pattern_;
+ return std::tie(id_, pattern_) < std::tie(rhs.id_, rhs.pattern_);
}
} // namespace url_matcher