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.
 | 
			
		||||
 * @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());
 | 
			
		||||
	ObjectLock olock(this);
 | 
			
		||||
 | 
			
		||||
@ -53,7 +53,7 @@ public:
 | 
			
		||||
	Iterator End(void);
 | 
			
		||||
 | 
			
		||||
	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 Remove(unsigned int index);
 | 
			
		||||
 | 
			
		||||
@ -200,14 +200,7 @@ Value InExpression::DoEvaluate(const Object::Ptr& context, DebugHint *dhint) con
 | 
			
		||||
	Value left = m_Operand1->Evaluate(context);
 | 
			
		||||
		
 | 
			
		||||
	Array::Ptr arr = right;
 | 
			
		||||
	ObjectLock olock(arr);
 | 
			
		||||
	BOOST_FOREACH(const Value& value, arr) {
 | 
			
		||||
		if (value == left) {
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return false;
 | 
			
		||||
	return arr->Contains(left);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
 | 
			
		||||
	Array::Ptr arr = right;
 | 
			
		||||
	ObjectLock olock(arr);
 | 
			
		||||
	BOOST_FOREACH(const Value& value, arr) {
 | 
			
		||||
		if (value == left)
 | 
			
		||||
			return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return true;
 | 
			
		||||
	return !arr->Contains(left);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Value LogicalAndExpression::DoEvaluate(const Object::Ptr& context, DebugHint *dhint) const
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user