Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(813)

Unified Diff: net/der/input.cc

Issue 1664243002: Using == instead of Equals for der::Input comparison. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Using non-class equality. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/der/input.cc
diff --git a/net/der/input.cc b/net/der/input.cc
index 871f9f4ec7dc29a52d645f9c2194c2795d559394..49955905fa2d1f3db570b8badb4362dab5763330 100644
--- a/net/der/input.cc
+++ b/net/der/input.cc
@@ -24,12 +24,6 @@ Input::Input(const base::StringPiece& in)
Input::Input(const std::string* s) : Input(base::StringPiece(*s)) {}
-bool Input::Equals(const Input& other) const {
- if (len_ != other.len_)
- return false;
- return memcmp(data_, other.data_, len_) == 0;
-}
-
std::string Input::AsString() const {
return std::string(reinterpret_cast<const char*>(data_), len_);
}
@@ -38,6 +32,16 @@ base::StringPiece Input::AsStringPiece() const {
return base::StringPiece(reinterpret_cast<const char*>(data_), len_);
}
+bool operator==(const Input& lhs, const Input& rhs) {
+ if (lhs.Length() != rhs.Length())
+ return false;
+ return memcmp(lhs.UnsafeData(), rhs.UnsafeData(), lhs.Length()) == 0;
+}
+
+bool operator!=(const Input& lhs, const Input& rhs) {
+ return !(lhs == rhs);
+}
+
bool operator<(const Input& lhs, const Input& rhs) {
return std::lexicographical_compare(
lhs.UnsafeData(), lhs.UnsafeData() + lhs.Length(), rhs.UnsafeData(),
« net/der/input.h ('K') | « net/der/input.h ('k') | net/der/input_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698