From 61c05bfb458f079d7684c2fe12c8b26422eeb960 Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 30 Jul 2014 11:28:23 +0100 Subject: [PATCH] re-use feature_collection_grammar --- plugins/input/geojson/geojson_datasource.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index b05ad5a81..00636a5fe 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -145,24 +145,22 @@ geojson_datasource::geojson_datasource(parameters const& params) } } +namespace { +using base_iterator_type = std::istreambuf_iterator; +const mapnik::transcoder tr("utf8"); +const mapnik::json::feature_collection_grammar,mapnik::feature_impl> fc_grammar(tr); +} + template void geojson_datasource::parse_geojson(T & stream) { - using base_iterator_type = std::istreambuf_iterator; boost::spirit::multi_pass begin = boost::spirit::make_default_multi_pass(base_iterator_type(stream)); boost::spirit::multi_pass end = boost::spirit::make_default_multi_pass(base_iterator_type()); - // FIXME - for perf we need to declare grammar as 'static const' - // but we cannot because then all features will interact only with the first context_ptr - // created in the process which leads to very odd bugs - - mapnik::transcoder tr("utf8"); - mapnik::json::feature_collection_grammar,mapnik::feature_impl> fc_grammar(tr); boost::spirit::standard_wide::space_type space; - mapnik::context_ptr ctx = std::make_shared(); bool result = boost::spirit::qi::phrase_parse(begin, end, (fc_grammar)(boost::phoenix::ref(ctx)), space, features_); if (!result)