Use Array::Contains in InExpression/NotInExpression

This commit is contained in:
Gunnar Beutner 2014-11-15 08:22:09 +01:00
parent f73d69691b
commit 814589ac17
3 changed files with 4 additions and 17 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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