From 06592cedc33db16dac6412b93242c72a756b61ab Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 29 Nov 2013 13:51:50 +0000 Subject: [PATCH] re-use evaluator object --- include/mapnik/expression_evaluator.hpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/include/mapnik/expression_evaluator.hpp b/include/mapnik/expression_evaluator.hpp index f6c4334da..7da728301 100644 --- a/include/mapnik/expression_evaluator.hpp +++ b/include/mapnik/expression_evaluator.hpp @@ -38,6 +38,7 @@ namespace mapnik { + template struct evaluate : boost::static_visitor { @@ -79,7 +80,7 @@ struct evaluate : boost::static_visitor value_type operator() (global_attribute const& attr) const { - return value_type();// shouldn't get here ? //attr.value(feature_); + return value_type();// shouldn't get here } value_type operator() (geometry_type_attribute const& geom) const @@ -89,22 +90,22 @@ struct evaluate : boost::static_visitor value_type operator() (binary_node const & x) const { - return (boost::apply_visitor(evaluate(feature_),x.left).to_bool()) - && (boost::apply_visitor(evaluate(feature_),x.right).to_bool()); + return (boost::apply_visitor(*this, x.left).to_bool()) + && (boost::apply_visitor(*this, x.right).to_bool()); } value_type operator() (binary_node const & x) const { - return (boost::apply_visitor(evaluate(feature_),x.left).to_bool()) - || (boost::apply_visitor(evaluate(feature_),x.right).to_bool()); + return (boost::apply_visitor(*this,x.left).to_bool()) + || (boost::apply_visitor(*this,x.right).to_bool()); } template value_type operator() (binary_node const& x) const { typename make_op::type operation; - return operation(boost::apply_visitor(evaluate(feature_),x.left), - boost::apply_visitor(evaluate(feature_),x.right)); + return operation(boost::apply_visitor(*this, x.left), + boost::apply_visitor(*this, x.right)); } template @@ -116,12 +117,12 @@ struct evaluate : boost::static_visitor value_type operator() (unary_node const& x) const { - return ! (boost::apply_visitor(evaluate(feature_),x.expr).to_bool()); + return ! (boost::apply_visitor(*this,x.expr).to_bool()); } value_type operator() (regex_match_node const& x) const { - value_type v = boost::apply_visitor(evaluate(feature_),x.expr); + value_type v = boost::apply_visitor(*this, x.expr); #if defined(BOOST_REGEX_HAS_ICU) return boost::u32regex_match(v.to_unicode(),x.pattern); #else @@ -132,7 +133,7 @@ struct evaluate : boost::static_visitor value_type operator() (regex_replace_node const& x) const { - value_type v = boost::apply_visitor(evaluate(feature_),x.expr); + value_type v = boost::apply_visitor(*this, x.expr); #if defined(BOOST_REGEX_HAS_ICU) return boost::u32regex_replace(v.to_unicode(),x.pattern,x.format); #else