You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by al...@apache.org on 2023/06/10 05:37:37 UTC
[kudu] 02/03: [rpc] replace UserCredentials::Equals() with operator==()
This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
commit 99132b09cc8faa81f55c070ee1f6731886c6180a
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Fri Jun 9 18:26:15 2023 -0700
[rpc] replace UserCredentials::Equals() with operator==()
The motivation for this change is a realisation that methods like
Equals() look a bit funny in C++ code since the language supports
much more expressive and readable notation for comparing objects.
This patch doesn't contain any functional changes.
Change-Id: Ic8e1b223e2f8f5345b339568902a485c833e7d86
Reviewed-on: http://gerrit.cloudera.org:8080/20032
Reviewed-by: Abhishek Chennaka <ac...@cloudera.com>
Tested-by: Alexey Serbin <al...@apache.org>
---
src/kudu/rpc/connection_id.cc | 2 +-
src/kudu/rpc/user_credentials.cc | 6 +-----
src/kudu/rpc/user_credentials.h | 10 ++++++++--
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/kudu/rpc/connection_id.cc b/src/kudu/rpc/connection_id.cc
index 8a14d83e2..474eb0a0f 100644
--- a/src/kudu/rpc/connection_id.cc
+++ b/src/kudu/rpc/connection_id.cc
@@ -81,7 +81,7 @@ size_t ConnectionId::HashCode() const {
bool ConnectionId::Equals(const ConnectionId& other) const {
return remote() == other.remote() &&
hostname_ == other.hostname_ &&
- user_credentials().Equals(other.user_credentials()) &&
+ user_credentials() == other.user_credentials() &&
network_plane_ == other.network_plane_;
}
diff --git a/src/kudu/rpc/user_credentials.cc b/src/kudu/rpc/user_credentials.cc
index 7f318fed9..a836438f8 100644
--- a/src/kudu/rpc/user_credentials.cc
+++ b/src/kudu/rpc/user_credentials.cc
@@ -21,7 +21,7 @@
#include <string>
#include <utility>
-#include <boost/functional/hash/hash.hpp>
+#include <boost/container_hash/extensions.hpp>
#include "kudu/gutil/strings/substitute.h"
#include "kudu/util/status.h"
@@ -56,9 +56,5 @@ size_t UserCredentials::HashCode() const {
return seed;
}
-bool UserCredentials::Equals(const UserCredentials& other) const {
- return real_user() == other.real_user();
-}
-
} // namespace rpc
} // namespace kudu
diff --git a/src/kudu/rpc/user_credentials.h b/src/kudu/rpc/user_credentials.h
index 5a0434cf2..6bf7b2afa 100644
--- a/src/kudu/rpc/user_credentials.h
+++ b/src/kudu/rpc/user_credentials.h
@@ -42,10 +42,16 @@ class UserCredentials {
std::string ToString() const;
std::size_t HashCode() const;
- bool Equals(const UserCredentials& other) const;
+
+ bool operator==(const UserCredentials& other) const {
+ return real_user_ == other.real_user_;
+ }
+ bool operator!=(const UserCredentials& other) const {
+ return !(*this == other);
+ }
private:
- // Remember to update HashCode() and Equals() when new fields are added.
+ // Remember to update HashCode() and operator==() when new fields are added.
std::string real_user_;
};