diff options
author | jsbell <jsbell@chromium.org> | 2015-11-19 17:29:49 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-20 01:30:32 +0000 |
commit | 0a0c449a5af92bdca0e37d539617e9d4dffae220 (patch) | |
tree | 02a6c54ecb222cee9615eea22591fbda6f483596 | |
parent | 7faa086b0179eea33c7cb9ded9964dc560ca42bd (diff) | |
download | chromium_src-0a0c449a5af92bdca0e37d539617e9d4dffae220.zip chromium_src-0a0c449a5af92bdca0e37d539617e9d4dffae220.tar.gz chromium_src-0a0c449a5af92bdca0e37d539617e9d4dffae220.tar.bz2 |
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
Review URL: https://codereview.chromium.org/1456263005
Cr-Commit-Position: refs/heads/master@{#360707}
8 files changed, 55 insertions, 39 deletions
diff --git a/components/autofill/core/common/form_data.cc b/components/autofill/core/common/form_data.cc index 3d68639..aaa8178f 100644 --- a/components/autofill/core/common/form_data.cc +++ b/components/autofill/core/common/form_data.cc @@ -4,8 +4,6 @@ #include "components/autofill/core/common/form_data.h" -#include <tuple> - #include "base/base64.h" #include "base/pickle.h" #include "base/strings/string_util.h" @@ -88,9 +86,15 @@ bool FormData::SameFormAs(const FormData& form) const { } bool FormData::operator<(const FormData& form) const { - return std::tie(name, origin, action, is_form_tag, fields) < - std::tie(form.name, form.origin, form.action, form.is_form_tag, - form.fields); + 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; } 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 54db610..1ae3446 100644 --- a/components/autofill/core/common/form_field_data.cc +++ b/components/autofill/core/common/form_field_data.cc @@ -4,8 +4,6 @@ #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" @@ -119,15 +117,29 @@ 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 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); + return false; } 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 1c35ba2..148b5c2 100644 --- a/components/autofill/core/common/password_form_fill_data.cc +++ b/components/autofill/core/common/password_form_fill_data.cc @@ -4,8 +4,6 @@ #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" @@ -17,8 +15,11 @@ UsernamesCollectionKey::~UsernamesCollectionKey() {} bool UsernamesCollectionKey::operator<( const UsernamesCollectionKey& other) const { - return std::tie(username, password, realm) < - std::tie(other.username, other.password, other.realm); + if (username != other.username) + return username < other.username; + if (password != other.password) + return password < other.password; + return realm < 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 0c3ab90..d51e624 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,8 +4,6 @@ #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" @@ -63,8 +61,9 @@ OriginIdentifierValueMap::EntryMapKey::EntryMapKey( bool OriginIdentifierValueMap::EntryMapKey::operator<( const OriginIdentifierValueMap::EntryMapKey& other) const { - return std::tie(content_type, resource_identifier) < - std::tie(other.content_type, other.resource_identifier); + if (content_type != other.content_type) + return content_type < other.content_type; + return (resource_identifier < other.resource_identifier); } OriginIdentifierValueMap::PatternPair::PatternPair( @@ -79,8 +78,11 @@ bool OriginIdentifierValueMap::PatternPair::operator<( // Note that this operator is the other way around than // |ContentSettingsPattern::operator<|. It sorts patterns with higher // precedence first. - return std::tie(primary_pattern, secondary_pattern) > - std::tie(other.primary_pattern, other.secondary_pattern); + if (primary_pattern > other.primary_pattern) + return true; + else if (other.primary_pattern > primary_pattern) + return false; + return (secondary_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 c93f953..4c86e9d 100644 --- a/components/guest_view/browser/guest_view_manager.cc +++ b/components/guest_view/browser/guest_view_manager.cc @@ -4,8 +4,6 @@ #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" @@ -478,8 +476,10 @@ GuestViewManager::ElementInstanceKey::ElementInstanceKey( bool GuestViewManager::ElementInstanceKey::operator<( const GuestViewManager::ElementInstanceKey& other) const { - return std::tie(embedder_process_id, element_instance_id) < - std::tie(other.embedder_process_id, other.element_instance_id); + if (embedder_process_id != other.embedder_process_id) + return embedder_process_id < other.embedder_process_id; + + return element_instance_id < other.element_instance_id; } bool GuestViewManager::ElementInstanceKey::operator==( diff --git a/components/mus/ws/ids.h b/components/mus/ws/ids.h index 8ae41c9..3c814d0 100644 --- a/components/mus/ws/ids.h +++ b/components/mus/ws/ids.h @@ -5,8 +5,6 @@ #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" @@ -31,8 +29,10 @@ struct WindowId { bool operator!=(const WindowId& other) const { return !(*this == other); } bool operator<(const WindowId& other) const { - return std::tie(connection_id, window_id) < - std::tie(other.connection_id, other.window_id); + if (connection_id == other.connection_id) + return window_id < other.window_id; + + return connection_id < other.connection_id; } ConnectionSpecificId connection_id; diff --git a/components/policy/core/common/policy_namespace.cc b/components/policy/core/common/policy_namespace.cc index 33a9992..0fac9ca 100644 --- a/components/policy/core/common/policy_namespace.cc +++ b/components/policy/core/common/policy_namespace.cc @@ -4,8 +4,6 @@ #include "components/policy/core/common/policy_namespace.h" -#include <tuple> - namespace policy { PolicyNamespace::PolicyNamespace() {} @@ -28,8 +26,8 @@ PolicyNamespace& PolicyNamespace::operator=(const PolicyNamespace& other) { } bool PolicyNamespace::operator<(const PolicyNamespace& other) const { - return std::tie(domain, component_id) < - std::tie(other.domain, other.component_id); + return domain < other.domain || + (domain == other.domain && component_id < 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 a4b87bc..d103bce 100644 --- a/components/url_matcher/string_pattern.cc +++ b/components/url_matcher/string_pattern.cc @@ -4,8 +4,6 @@ #include "components/url_matcher/string_pattern.h" -#include <tuple> - namespace url_matcher { StringPattern::StringPattern(const std::string& pattern, @@ -15,7 +13,8 @@ StringPattern::StringPattern(const std::string& pattern, StringPattern::~StringPattern() {} bool StringPattern::operator<(const StringPattern& rhs) const { - return std::tie(id_, pattern_) < std::tie(rhs.id_, rhs.pattern_); + if (id_ != rhs.id_) return id_ < rhs.id_; + return pattern_ < rhs.pattern_; } } // namespace url_matcher |