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 a10b94917860a09792475f28cc3e7bd9eae45fb3 Author: Alexey Serbin <[email protected]> AuthorDate: Fri Jun 9 19:54:48 2023 -0700 [rpc] replace ConnectionId::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, just syntactic sugar. Change-Id: Iea46d847d5ae77075ed6f364abc7a39e39800d6d Reviewed-on: http://gerrit.cloudera.org:8080/20033 Reviewed-by: Abhishek Chennaka <[email protected]> Tested-by: Alexey Serbin <[email protected]> --- src/kudu/rpc/connection_id.cc | 4 ++-- src/kudu/rpc/connection_id.h | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/kudu/rpc/connection_id.cc b/src/kudu/rpc/connection_id.cc index 474eb0a0f..de488c66e 100644 --- a/src/kudu/rpc/connection_id.cc +++ b/src/kudu/rpc/connection_id.cc @@ -78,7 +78,7 @@ size_t ConnectionId::HashCode() const { return seed; } -bool ConnectionId::Equals(const ConnectionId& other) const { +bool ConnectionId::operator==(const ConnectionId& other) const { return remote() == other.remote() && hostname_ == other.hostname_ && user_credentials() == other.user_credentials() && @@ -90,7 +90,7 @@ size_t ConnectionIdHash::operator() (const ConnectionId& conn_id) const { } bool ConnectionIdEqual::operator() (const ConnectionId& cid1, const ConnectionId& cid2) const { - return cid1.Equals(cid2); + return cid1 == cid2; } } // namespace rpc diff --git a/src/kudu/rpc/connection_id.h b/src/kudu/rpc/connection_id.h index 0aed953e9..145e1f205 100644 --- a/src/kudu/rpc/connection_id.h +++ b/src/kudu/rpc/connection_id.h @@ -63,10 +63,13 @@ class ConnectionId { std::string ToString() const; size_t HashCode() const; - bool Equals(const ConnectionId& other) const; + bool operator==(const ConnectionId& other) const; + bool operator!=(const ConnectionId& 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. Sockaddr remote_; // The original host name before it was resolved to 'remote_'.
