diff --git a/search/geocoder.cpp b/search/geocoder.cpp index f808b30609..ab84c98cd0 100644 --- a/search/geocoder.cpp +++ b/search/geocoder.cpp @@ -659,8 +659,7 @@ void Geocoder::InitBaseContext(BaseContext & ctx) for (size_t i = 0; i < ctx.m_features.size(); ++i) { PrepareRetrievalParams(i, i + 1); - ctx.m_features[i] = RetrieveAddressFeatures(m_context->GetId(), m_context->m_value, - m_cancellable, m_retrievalParams); + ctx.m_features[i] = RetrieveAddressFeatures(*m_context, m_cancellable, m_retrievalParams); } } @@ -1417,8 +1416,7 @@ CBV Geocoder::LoadCategories(MwmContext & context, vector co for_each(categories.begin(), categories.end(), [&](strings::UniString const & category) { m_retrievalParams.m_tokens[0][0] = category; - CBV cbv(RetrieveAddressFeatures(context.GetId(), context.m_value, m_cancellable, - m_retrievalParams)); + CBV cbv(RetrieveAddressFeatures(context, m_cancellable, m_retrievalParams)); if (!cbv.IsEmpty()) cbvs.push_back(move(cbv)); }); @@ -1454,8 +1452,7 @@ CBV Geocoder::LoadVillages(MwmContext & context) CBV Geocoder::RetrievePostcodeFeatures(MwmContext const & context, TokenSlice const & slice) { - return CBV( - ::search::RetrievePostcodeFeatures(context.GetId(), context.m_value, m_cancellable, slice)); + return CBV(::search::RetrievePostcodeFeatures(context, m_cancellable, slice)); } CBV Geocoder::RetrieveGeometryFeatures(MwmContext const & context, m2::RectD const & rect, diff --git a/search/mwm_context.hpp b/search/mwm_context.hpp index 6038c9188c..aae3a8c0b8 100644 --- a/search/mwm_context.hpp +++ b/search/mwm_context.hpp @@ -32,6 +32,7 @@ private: public: explicit MwmContext(MwmSet::MwmHandle handle); + inline bool IsAlive() const { return m_handle.IsAlive(); } inline MwmSet::MwmId const & GetId() const { return m_handle.GetId(); } inline string const & GetName() const { return GetInfo()->GetCountryName(); } inline shared_ptr const & GetInfo() const { return GetId().GetInfo(); } diff --git a/search/retrieval.cpp b/search/retrieval.cpp index 8a312d8f6b..87051e731b 100644 --- a/search/retrieval.cpp +++ b/search/retrieval.cpp @@ -198,51 +198,43 @@ void WithSearchTrieRoot(MwmValue & value, TFn && fn) // features matching to |params|. template unique_ptr RetrieveAddressFeaturesImpl( - MwmSet::MwmId const & id, MwmValue & value, my::Cancellable const & cancellable, - QueryParams const & params) + MwmContext const & context, my::Cancellable const & cancellable, QueryParams const & params) { - EditedFeaturesHolder holder(id); + EditedFeaturesHolder holder(context.GetId()); vector features; FeaturesCollector collector(cancellable, features); - WithSearchTrieRoot(value, [&](TrieRoot const & root) - { - MatchFeaturesInTrie(params, root, [&holder](uint32_t featureIndex) - { - return !holder.ModifiedOrDeleted(featureIndex); - }, - collector); + WithSearchTrieRoot(context.m_value, [&](TrieRoot const & root) { + MatchFeaturesInTrie( + params, root, + [&holder](uint32_t featureIndex) { return !holder.ModifiedOrDeleted(featureIndex); }, + collector); + }); + holder.ForEachModifiedOrCreated([&](FeatureType & ft, uint64_t index) { + if (MatchFeatureByName(ft, params)) + features.push_back(index); }); - holder.ForEachModifiedOrCreated([&](FeatureType & ft, uint64_t index) - { - if (MatchFeatureByName(ft, params)) - features.push_back(index); - }); return SortFeaturesAndBuildCBV(move(features)); } template unique_ptr RetrievePostcodeFeaturesImpl( - MwmSet::MwmId const & id, MwmValue & value, my::Cancellable const & cancellable, - TokenSlice const & slice) + MwmContext const & context, my::Cancellable const & cancellable, TokenSlice const & slice) { - EditedFeaturesHolder holder(id); + EditedFeaturesHolder holder(context.GetId()); vector features; FeaturesCollector collector(cancellable, features); - WithSearchTrieRoot(value, [&](TrieRoot const & root) - { - MatchPostcodesInTrie(slice, root, [&holder](uint32_t featureIndex) - { - return !holder.ModifiedOrDeleted(featureIndex); - }, - collector); + WithSearchTrieRoot(context.m_value, [&](TrieRoot const & root) { + MatchPostcodesInTrie( + slice, root, + [&holder](uint32_t featureIndex) { return !holder.ModifiedOrDeleted(featureIndex); }, + collector); + }); + holder.ForEachModifiedOrCreated([&](FeatureType & ft, uint64_t index) { + if (MatchFeatureByPostcode(ft, slice)) + features.push_back(index); }); - holder.ForEachModifiedOrCreated([&](FeatureType & ft, uint64_t index) - { - if (MatchFeatureByPostcode(ft, slice)) - features.push_back(index); - }); return SortFeaturesAndBuildCBV(move(features)); } @@ -284,52 +276,48 @@ template