mirror of
				https://github.com/bblanchon/ArduinoJson.git
				synced 2025-11-04 00:21:36 +01:00 
			
		
		
		
	Simplify JsonArray::operator==
				
					
				
			This commit is contained in:
		@@ -85,7 +85,7 @@ class JsonArray : public detail::VariantOperators<JsonArray> {
 | 
			
		||||
 | 
			
		||||
  // Compares the content of two arrays.
 | 
			
		||||
  FORCE_INLINE bool operator==(JsonArray rhs) const {
 | 
			
		||||
    return JsonArrayConst(data_) == JsonArrayConst(rhs.data_);
 | 
			
		||||
    return arrayEquals(data_, rhs.data_);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Removes the element at the specified iterator.
 | 
			
		||||
 
 | 
			
		||||
@@ -45,12 +45,7 @@ class JsonArrayConst : public detail::VariantOperators<JsonArrayConst> {
 | 
			
		||||
  // Compares the content of two arrays.
 | 
			
		||||
  // Returns true if the two arrays are equal.
 | 
			
		||||
  FORCE_INLINE bool operator==(JsonArrayConst rhs) const {
 | 
			
		||||
    if (data_ == rhs.data_)
 | 
			
		||||
      return true;
 | 
			
		||||
    if (!data_ || !rhs.data_)
 | 
			
		||||
      return false;
 | 
			
		||||
 | 
			
		||||
    return arrayEquals(*data_, *rhs.data_);
 | 
			
		||||
    return arrayEquals(data_, rhs.data_);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Returns the element at the specified index.
 | 
			
		||||
 
 | 
			
		||||
@@ -54,6 +54,8 @@ inline VariantData* collectionToVariant(CollectionData* collection) {
 | 
			
		||||
 | 
			
		||||
bool arrayEquals(const detail::CollectionData& lhs,
 | 
			
		||||
                 const detail::CollectionData& rhs);
 | 
			
		||||
bool arrayEquals(const detail::CollectionData* lhs,
 | 
			
		||||
                 const detail::CollectionData* rhs);
 | 
			
		||||
bool objectEquals(const detail::CollectionData& lhs,
 | 
			
		||||
                  const detail::CollectionData& rhs);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -116,6 +116,15 @@ inline bool arrayEquals(const CollectionData& lhs, const CollectionData& rhs) {
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline bool arrayEquals(const CollectionData* lhs, const CollectionData* rhs) {
 | 
			
		||||
  if (lhs == rhs)
 | 
			
		||||
    return true;
 | 
			
		||||
  if (!lhs || !rhs)
 | 
			
		||||
    return false;
 | 
			
		||||
 | 
			
		||||
  return arrayEquals(*lhs, *rhs);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline bool objectEquals(const CollectionData& lhs, const CollectionData& rhs) {
 | 
			
		||||
  size_t count = 0;
 | 
			
		||||
  for (auto a = lhs.head(); a; a = a->next()) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user