mirror of
				https://github.com/Icinga/icinga2.git
				synced 2025-11-03 21:25:56 +01:00 
			
		
		
		
	Use Array::Contains in InExpression/NotInExpression
This commit is contained in:
		
							parent
							
								
									f73d69691b
								
							
						
					
					
						commit
						814589ac17
					
				@ -115,7 +115,7 @@ size_t Array::GetLength(void) const
 | 
				
			|||||||
 * @param value The value.
 | 
					 * @param value The value.
 | 
				
			||||||
 * @returns true if the array contains the value, false otherwise.
 | 
					 * @returns true if the array contains the value, false otherwise.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
bool Array::Contains(const String& value) const
 | 
					bool Array::Contains(const Value& value) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	ASSERT(!OwnsLock());
 | 
						ASSERT(!OwnsLock());
 | 
				
			||||||
	ObjectLock olock(this);
 | 
						ObjectLock olock(this);
 | 
				
			||||||
 | 
				
			|||||||
@ -53,7 +53,7 @@ public:
 | 
				
			|||||||
	Iterator End(void);
 | 
						Iterator End(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	size_t GetLength(void) const;
 | 
						size_t GetLength(void) const;
 | 
				
			||||||
	bool Contains(const String& value) const;
 | 
						bool Contains(const Value& value) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void Insert(unsigned int index, const Value& value);
 | 
						void Insert(unsigned int index, const Value& value);
 | 
				
			||||||
	void Remove(unsigned int index);
 | 
						void Remove(unsigned int index);
 | 
				
			||||||
 | 
				
			|||||||
@ -200,14 +200,7 @@ Value InExpression::DoEvaluate(const Object::Ptr& context, DebugHint *dhint) con
 | 
				
			|||||||
	Value left = m_Operand1->Evaluate(context);
 | 
						Value left = m_Operand1->Evaluate(context);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
	Array::Ptr arr = right;
 | 
						Array::Ptr arr = right;
 | 
				
			||||||
	ObjectLock olock(arr);
 | 
						return arr->Contains(left);
 | 
				
			||||||
	BOOST_FOREACH(const Value& value, arr) {
 | 
					 | 
				
			||||||
		if (value == left) {
 | 
					 | 
				
			||||||
			return true;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return false;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Value NotInExpression::DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const
 | 
					Value NotInExpression::DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const
 | 
				
			||||||
@ -222,13 +215,7 @@ Value NotInExpression::DoEvaluate(const Object::Ptr& context, DebugHint *dhint)
 | 
				
			|||||||
	Value left = m_Operand1->Evaluate(context);
 | 
						Value left = m_Operand1->Evaluate(context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Array::Ptr arr = right;
 | 
						Array::Ptr arr = right;
 | 
				
			||||||
	ObjectLock olock(arr);
 | 
						return !arr->Contains(left);
 | 
				
			||||||
	BOOST_FOREACH(const Value& value, arr) {
 | 
					 | 
				
			||||||
		if (value == left)
 | 
					 | 
				
			||||||
			return false;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return true;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Value LogicalAndExpression::DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const
 | 
					Value LogicalAndExpression::DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user