diff --git a/libwccl/ops/equals.h b/libwccl/ops/equals.h index c646208d18648d943739ae7ea5c8e99a61dc83eb..1c2964469b21fab3ca75722eaa9a0b3bfe33cd3d 100644 --- a/libwccl/ops/equals.h +++ b/libwccl/ops/equals.h @@ -44,8 +44,8 @@ protected: * False otherwise. */ virtual BaseRetValPtr apply_internal(const FunExecContext& context) const { - boost::shared_ptr<T> arg1 = this->arg1_expr_->apply(context); - boost::shared_ptr<T> arg2 = this->arg2_expr_->apply(context); + const boost::shared_ptr<const T>& arg1 = this->arg1_expr_->apply(context); + const boost::shared_ptr<const T>& arg2 = this->arg2_expr_->apply(context); if(arg1->equals(*arg2)) { return Predicate::True(context); } @@ -87,22 +87,14 @@ protected: typedef FunctionBase::BaseRetValPtr BaseRetValPtr; /** - * Take values of arguments from expressions and return True if they are equal, - * False otherwise. + * Take values of arguments from expressions and return True if Positions + * are equal, in given context, False otherwise. */ virtual BaseRetValPtr apply_internal(const FunExecContext& context) const { - boost::shared_ptr<Position> arg1 = this->arg1_expr_->apply(context); - boost::shared_ptr<Position> arg2 = this->arg2_expr_->apply(context); - if(arg1->equals(*arg2)) { + const boost::shared_ptr<const Position>& arg1 = this->arg1_expr_->apply(context); + const boost::shared_ptr<const Position>& arg2 = this->arg2_expr_->apply(context); + if(arg1->equals(*arg2, context.sentence_context())) { return Predicate::True(context); - } else { - //in the given context both positions can still point nowhere - //even if they have different underlying value - int abs_pos1 = context.get_abs_position(*arg1); - int abs_pos2 = context.get_abs_position(*arg2); - if(!context.is_inside(abs_pos1) && !context.is_inside(abs_pos2)) { - return Predicate::True(context); - } } return Predicate::False(context); }