diff --git a/lib/base/array.cpp b/lib/base/array.cpp index c6a79bf4a..6b4ad2114 100644 --- a/lib/base/array.cpp +++ b/lib/base/array.cpp @@ -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); diff --git a/lib/base/array.hpp b/lib/base/array.hpp index 7459348ab..e721cc0e6 100644 --- a/lib/base/array.hpp +++ b/lib/base/array.hpp @@ -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); diff --git a/lib/config/expression.cpp b/lib/config/expression.cpp index 7135e4c64..d3f6914e3 100644 --- a/lib/config/expression.cpp +++ b/lib/config/expression.cpp @@ -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