Simplify few comparison helpers Change-Id: Id2ec35da6579c81d193663353d40872a9bebda38 Reviewed-on: https://weave-review.googlesource.com/2736 Reviewed-by: Alex Vakulenko <avakulenko@google.com>
diff --git a/src/access_revocation_manager.h b/src/access_revocation_manager.h index 6d5bf7b..ba2bcca 100644 --- a/src/access_revocation_manager.h +++ b/src/access_revocation_manager.h
@@ -52,8 +52,10 @@ inline bool operator==(const AccessRevocationManager::Entry& l, const AccessRevocationManager::Entry& r) { - return l.revocation == r.revocation && l.expiration == r.expiration && - l.user_id == r.user_id && l.app_id == r.app_id; + auto make_tuple = [](const AccessRevocationManager::Entry& e) { + return std::tie(e.revocation, e.expiration, e.user_id, e.app_id); + }; + return make_tuple(l) == make_tuple(r); } inline bool operator!=(const AccessRevocationManager::Entry& l,
diff --git a/src/access_revocation_manager_impl.h b/src/access_revocation_manager_impl.h index a911128..0ee253e 100644 --- a/src/access_revocation_manager_impl.h +++ b/src/access_revocation_manager_impl.h
@@ -40,11 +40,10 @@ struct EntryIdsLess { bool operator()(const Entry& l, const Entry& r) const { - if (l.user_id < r.user_id) - return true; - if (l.user_id > r.user_id) - return false; - return l.app_id < r.app_id; + auto make_tuple = [](const AccessRevocationManager::Entry& e) { + return std::tie(e.user_id, e.app_id); + }; + return make_tuple(l) < make_tuple(r); } };