optimize expression evaluation of text by avoiding extra copy
This commit is contained in:
parent
d3ab601e30
commit
1dd12755c6
2 changed files with 36 additions and 17 deletions
|
@ -47,9 +47,29 @@ struct evaluate : boost::static_visitor<T1>
|
||||||
explicit evaluate(feature_type const& f)
|
explicit evaluate(feature_type const& f)
|
||||||
: feature_(f) {}
|
: feature_(f) {}
|
||||||
|
|
||||||
value_type operator() (value_type x) const
|
value_integer operator() (value_integer val) const
|
||||||
{
|
{
|
||||||
return x;
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
value_double operator() (value_double val) const
|
||||||
|
{
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
value_bool operator() (value_bool val) const
|
||||||
|
{
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
value_null operator() (value_null val) const
|
||||||
|
{
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
value_unicode_string const& operator() (value_unicode_string const& str) const
|
||||||
|
{
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_type operator() (attribute const& attr) const
|
value_type operator() (attribute const& attr) const
|
||||||
|
|
|
@ -24,24 +24,17 @@
|
||||||
#define MAPNIK_EXPRESSION_NODE_TYPES_HPP
|
#define MAPNIK_EXPRESSION_NODE_TYPES_HPP
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
//#include <mapnik/value.hpp>
|
#include <mapnik/value_types.hpp>
|
||||||
//#include <mapnik/attribute.hpp>
|
#include <mapnik/value.hpp>
|
||||||
|
#include <mapnik/attribute.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/variant/variant_fwd.hpp>
|
#include <boost/mpl/vector/vector30.hpp>
|
||||||
|
#include <boost/variant.hpp>
|
||||||
namespace boost { template <typename T> class recursive_wrapper; }
|
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
|
|
||||||
struct attribute;
|
|
||||||
struct geometry_type_attribute;
|
|
||||||
namespace value_adl_barrier {
|
|
||||||
class value;
|
|
||||||
}
|
|
||||||
using value_adl_barrier::value;
|
|
||||||
|
|
||||||
namespace tags {
|
namespace tags {
|
||||||
struct negate
|
struct negate
|
||||||
{
|
{
|
||||||
|
@ -174,8 +167,12 @@ struct regex_replace_node;
|
||||||
|
|
||||||
typedef mapnik::value value_type;
|
typedef mapnik::value value_type;
|
||||||
|
|
||||||
typedef boost::variant <
|
typedef boost::mpl::vector24<
|
||||||
value_type,
|
value_null,
|
||||||
|
value_bool,
|
||||||
|
value_integer,
|
||||||
|
value_double,
|
||||||
|
value_unicode_string,
|
||||||
attribute,
|
attribute,
|
||||||
geometry_type_attribute,
|
geometry_type_attribute,
|
||||||
boost::recursive_wrapper<unary_node<tags::negate> >,
|
boost::recursive_wrapper<unary_node<tags::negate> >,
|
||||||
|
@ -195,7 +192,9 @@ boost::recursive_wrapper<binary_node<tags::logical_and> >,
|
||||||
boost::recursive_wrapper<binary_node<tags::logical_or> >,
|
boost::recursive_wrapper<binary_node<tags::logical_or> >,
|
||||||
boost::recursive_wrapper<regex_match_node>,
|
boost::recursive_wrapper<regex_match_node>,
|
||||||
boost::recursive_wrapper<regex_replace_node>
|
boost::recursive_wrapper<regex_replace_node>
|
||||||
> expr_node;
|
>::type expr_types;
|
||||||
|
|
||||||
|
typedef boost::make_recursive_variant_over<expr_types>::type expr_node;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue