diff --git a/map/promo_delegate.cpp b/map/promo_delegate.cpp index 7a1eca50fa..2026a72902 100644 --- a/map/promo_delegate.cpp +++ b/map/promo_delegate.cpp @@ -8,9 +8,8 @@ #include "base/string_utils.hpp" PromoDelegate::PromoDelegate(DataSource const & dataSource, search::CityFinder & cityFinder) - : m_dataSource(dataSource), m_cityFinder(cityFinder), m_cities(dataSource) + : m_dataSource(dataSource), m_cityFinder(cityFinder) { - m_cities.Load(); } std::string PromoDelegate::GetCityId(m2::PointD const & point) @@ -25,12 +24,18 @@ std::string PromoDelegate::GetCityId(m2::PointD const & point) if (!feature) return {}; - base::GeoObjectId id; - if (ftypes::IsPromoCatalogChecker::Instance()(*feature) && - m_cities.GetGeoObjectId(feature->GetID(), id)) + if (!ftypes::IsPromoCatalogChecker::Instance()(*feature)) + return {}; + + if (!m_cities) { - return strings::to_string(id); + m_cities = std::make_unique(m_dataSource); + m_cities->Load(); } + base::GeoObjectId id; + if (m_cities->GetGeoObjectId(feature->GetID(), id)) + return strings::to_string(id); + return {}; } diff --git a/map/promo_delegate.hpp b/map/promo_delegate.hpp index d9b5b9a473..7da68935c3 100644 --- a/map/promo_delegate.hpp +++ b/map/promo_delegate.hpp @@ -6,6 +6,7 @@ #include "geometry/point2d.hpp" +#include #include class DataSource; @@ -25,5 +26,5 @@ public: private: DataSource const & m_dataSource; search::CityFinder & m_cityFinder; - indexer::FeatureIdToGeoObjectIdBimap m_cities; + std::unique_ptr m_cities; };