summaryrefslogtreecommitdiffstats
path: root/extensions/common/permissions
diff options
context:
space:
mode:
authorjsbell <jsbell@chromium.org>2015-11-20 11:37:14 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-20 19:38:57 +0000
commit9a9ef2b842828e764ad7e120b6563025d27bdaad (patch)
treef9140076ad1fd6a8d6090158ba239a3c32dde03c /extensions/common/permissions
parentf38d62d883828354c5f4711307c6391a00a3e8a8 (diff)
downloadchromium_src-9a9ef2b842828e764ad7e120b6563025d27bdaad.zip
chromium_src-9a9ef2b842828e764ad7e120b6563025d27bdaad.tar.gz
chromium_src-9a9ef2b842828e764ad7e120b6563025d27bdaad.tar.bz2
Use std::tie() for operator< in extensions/
Simplify the code for operator< when comparing multiple members using a common std::tie idiom. BUG=555171 R=rdevlin.cronin@chromium.org Review URL: https://codereview.chromium.org/1461163002 Cr-Commit-Position: refs/heads/master@{#360879}
Diffstat (limited to 'extensions/common/permissions')
-rw-r--r--extensions/common/permissions/socket_permission_entry.cc23
-rw-r--r--extensions/common/permissions/usb_device_permission_data.cc10
2 files changed, 8 insertions, 25 deletions
diff --git a/extensions/common/permissions/socket_permission_entry.cc b/extensions/common/permissions/socket_permission_entry.cc
index 31ec6b8..926a07b 100644
--- a/extensions/common/permissions/socket_permission_entry.cc
+++ b/extensions/common/permissions/socket_permission_entry.cc
@@ -6,6 +6,7 @@
#include <cstdlib>
#include <sstream>
+#include <tuple>
#include <vector>
#include "base/logging.h"
@@ -43,24 +44,10 @@ SocketPermissionEntry::SocketPermissionEntry()
SocketPermissionEntry::~SocketPermissionEntry() {}
bool SocketPermissionEntry::operator<(const SocketPermissionEntry& rhs) const {
- if (pattern_.type < rhs.pattern_.type)
- return true;
- if (pattern_.type > rhs.pattern_.type)
- return false;
-
- if (pattern_.host < rhs.pattern_.host)
- return true;
- if (pattern_.host > rhs.pattern_.host)
- return false;
-
- if (match_subdomains_ < rhs.match_subdomains_)
- return true;
- if (match_subdomains_ > rhs.match_subdomains_)
- return false;
-
- if (pattern_.port < rhs.pattern_.port)
- return true;
- return false;
+ return std::tie(pattern_.type, pattern_.host, match_subdomains_,
+ pattern_.port) <
+ std::tie(rhs.pattern_.type, rhs.pattern_.host, rhs.match_subdomains_,
+ rhs.pattern_.port);
}
bool SocketPermissionEntry::operator==(const SocketPermissionEntry& rhs) const {
diff --git a/extensions/common/permissions/usb_device_permission_data.cc b/extensions/common/permissions/usb_device_permission_data.cc
index 532886d..fbd4428 100644
--- a/extensions/common/permissions/usb_device_permission_data.cc
+++ b/extensions/common/permissions/usb_device_permission_data.cc
@@ -5,6 +5,7 @@
#include "extensions/common/permissions/usb_device_permission_data.h"
#include <string>
+#include <tuple>
#include <vector>
#include "base/basictypes.h"
@@ -90,13 +91,8 @@ bool UsbDevicePermissionData::FromValue(const base::Value* value) {
bool UsbDevicePermissionData::operator<(
const UsbDevicePermissionData& rhs) const {
- if (vendor_id_ == rhs.vendor_id_) {
- if (product_id_ == rhs.product_id_)
- return interface_id_ < rhs.interface_id_;
-
- return product_id_ < rhs.product_id_;
- }
- return vendor_id_ < rhs.vendor_id_;
+ return std::tie(vendor_id_, product_id_, interface_id_) <
+ std::tie(rhs.vendor_id_, rhs.product_id_, rhs.interface_id_);
}
bool UsbDevicePermissionData::operator==(