Skip to content

Commit 351ed02

Browse files
[Support] Simplify Object::operator== (NFC)
This patch simplifies Object::operator== with DenseMap::operator==.
1 parent 59d72b5 commit 351ed02

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

llvm/include/llvm/Support/JSON.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ class Object {
153153
LLVM_ABI json::Object *getObject(StringRef K);
154154
LLVM_ABI const json::Array *getArray(StringRef K) const;
155155
LLVM_ABI json::Array *getArray(StringRef K);
156+
157+
friend bool operator==(const Object &LHS, const Object &RHS);
156158
};
157159
LLVM_ABI bool operator==(const Object &LHS, const Object &RHS);
158160
inline bool operator!=(const Object &LHS, const Object &RHS) {

llvm/lib/Support/JSON.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,7 @@ json::Array *Object::getArray(StringRef K) {
8484
return V->getAsArray();
8585
return nullptr;
8686
}
87-
bool operator==(const Object &LHS, const Object &RHS) {
88-
if (LHS.size() != RHS.size())
89-
return false;
90-
for (const auto &L : LHS) {
91-
auto R = RHS.find(L.first);
92-
if (R == RHS.end() || L.second != R->second)
93-
return false;
94-
}
95-
return true;
96-
}
87+
bool operator==(const Object &LHS, const Object &RHS) { return LHS.M == RHS.M; }
9788

9889
Array::Array(std::initializer_list<Value> Elements) {
9990
V.reserve(Elements.size());

0 commit comments

Comments
 (0)