mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-02 00:38:26 +01:00
Implement comparison out of VariantData
This commit is contained in:
@@ -17,14 +17,6 @@ typename TVisitor::result_type objectAccept(const CollectionData *obj,
|
||||
return visitor.visitNull();
|
||||
}
|
||||
|
||||
inline bool objectEquals(const CollectionData *lhs, const CollectionData *rhs) {
|
||||
if (lhs == rhs)
|
||||
return true;
|
||||
if (!lhs || !rhs)
|
||||
return false;
|
||||
return lhs->equalsObject(*rhs);
|
||||
}
|
||||
|
||||
template <typename TAdaptedString>
|
||||
inline VariantData *objectGetMember(const CollectionData *obj,
|
||||
TAdaptedString key) {
|
||||
|
||||
@@ -127,7 +127,19 @@ class ObjectConstRef : public ObjectRefBase<const CollectionData>,
|
||||
}
|
||||
|
||||
FORCE_INLINE bool operator==(ObjectConstRef rhs) const {
|
||||
return objectEquals(_data, rhs._data);
|
||||
if (_data == rhs._data)
|
||||
return true;
|
||||
|
||||
if (!_data || !rhs._data)
|
||||
return false;
|
||||
|
||||
size_t count = 0;
|
||||
for (iterator it = begin(); it != end(); ++it) {
|
||||
if (it->value() != rhs[it->key()])
|
||||
return false;
|
||||
count++;
|
||||
}
|
||||
return count == rhs.size();
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -215,7 +227,7 @@ class ObjectRef : public ObjectRefBase<CollectionData>,
|
||||
}
|
||||
|
||||
FORCE_INLINE bool operator==(ObjectRef rhs) const {
|
||||
return objectEquals(_data, rhs._data);
|
||||
return ObjectConstRef(_data) == ObjectConstRef(rhs._data);
|
||||
}
|
||||
|
||||
FORCE_INLINE void remove(iterator it) const {
|
||||
|
||||
Reference in New Issue
Block a user