From a0b298211908036da269e7dcc2c78025476e2bf2 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 15 Jun 2016 14:55:45 -0700 Subject: [core] Prepare Filter and FilterEvaluator for extraction (#5366) --- benchmark/parse/filter.cpp | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) (limited to 'benchmark') diff --git a/benchmark/parse/filter.cpp b/benchmark/parse/filter.cpp index 7450fc7804..8beff3b308 100644 --- a/benchmark/parse/filter.cpp +++ b/benchmark/parse/filter.cpp @@ -13,32 +13,6 @@ using namespace mbgl; typedef std::multimap Properties; -class StubFeature : public GeometryTileFeature { -public: - inline StubFeature(const Properties& properties_, FeatureType type_) - : properties(properties_), type(type_) { - } - - optional getValue(const std::string& key) const override { - auto it = properties.find(key); - if (it == properties.end()) - return optional(); - return it->second; - } - - FeatureType getType() const override { - return type; - } - - GeometryCollection getGeometries() const override { - return GeometryCollection(); - } - -private: - const Properties properties; - FeatureType type; -}; - style::Filter parse(const char* expression) { rapidjson::GenericDocument, rapidjson::CrtAllocator> doc; doc.Parse<0>(expression); @@ -54,10 +28,14 @@ static void Parse_Filter(benchmark::State& state) { static void Parse_EvaluateFilter(benchmark::State& state) { const style::Filter filter = parse(R"FILTER(["==", "foo", "bar"])FILTER"); const Properties properties = { { "foo", std::string("bar") } }; - const StubFeature feature(properties, FeatureType::Unknown); while (state.KeepRunning()) { - style::Filter::visit(filter, style::FilterEvaluator{ feature }); + filter(FeatureType::Unknown, [&] (const std::string& key) -> optional { + auto it = properties.find(key); + if (it == properties.end()) + return {}; + return it->second; + }); } } -- cgit v1.2.1