From ab2a1f25a352479e736f2b7fabd87762721fca56 Mon Sep 17 00:00:00 2001 From: tatiana-yan Date: Thu, 3 Oct 2019 11:34:54 +0300 Subject: [PATCH] [search] Use ftypes::IsLocalityChecker instead of TypesSkepper::IsCountryOrState --- generator/search_index_builder.cpp | 12 +++++++++--- search/types_skipper.cpp | 13 ------------- search/types_skipper.hpp | 2 -- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/generator/search_index_builder.cpp b/generator/search_index_builder.cpp index 0d35085718..c7de4e9c0c 100644 --- a/generator/search_index_builder.cpp +++ b/generator/search_index_builder.cpp @@ -320,6 +320,13 @@ public: static TypesSkipper skipIndex; + auto const isCountryOrState = [](auto types) { + auto const & isLocalityChecker = ftypes::IsLocalityChecker::Instance(); + auto const localityType = isLocalityChecker.GetType(types); + return localityType == ftypes::LocalityType::Country || + localityType == ftypes::LocalityType::State; + }; + feature::TypesHolder types(f); auto const & streetChecker = ftypes::IsStreetOrSuburbChecker::Instance(); @@ -327,9 +334,8 @@ public: // Init inserter with serialized value. // Insert synonyms only for countries and states (maybe will add cities in future). - FeatureNameInserter inserter( - index, skipIndex.IsCountryOrState(types) ? m_synonyms : nullptr, m_keyValuePairs, - hasStreetType); + FeatureNameInserter inserter(index, isCountryOrState(types) ? m_synonyms : nullptr, + m_keyValuePairs, hasStreetType); string const postcode = f.GetMetadata().Get(feature::Metadata::FMD_POSTCODE); if (!postcode.empty()) diff --git a/search/types_skipper.cpp b/search/types_skipper.cpp index d9b1fc93fd..dfb7530a7a 100644 --- a/search/types_skipper.cpp +++ b/search/types_skipper.cpp @@ -59,19 +59,6 @@ void TypesSkipper::SkipEmptyNameTypes(feature::TypesHolder & types) const types.RemoveIf(shouldBeRemoved); } -bool TypesSkipper::IsCountryOrState(feature::TypesHolder const & types) const -{ - auto static const country = classif().GetTypeByPath({"place", "country"}); - auto static const state = classif().GetTypeByPath({"place", "state"}); - for (uint32_t t : types) - { - ftype::TruncValue(t, 2); - if (t == country || t == state) - return true; - } - return false; -} - // static bool TypesSkipper::HasType(Cont const & v, uint32_t t) { diff --git a/search/types_skipper.hpp b/search/types_skipper.hpp index 75d70e19ed..960a14363b 100644 --- a/search/types_skipper.hpp +++ b/search/types_skipper.hpp @@ -16,8 +16,6 @@ public: void SkipEmptyNameTypes(feature::TypesHolder & types) const; - bool IsCountryOrState(feature::TypesHolder const & types) const; - private: using Cont = buffer_vector;