From 279366ff82ba6c8c297cbf7fbf26700ae4908134 Mon Sep 17 00:00:00 2001 From: vng Date: Tue, 15 Mar 2016 20:16:01 +0300 Subject: [PATCH] Load HouseToStreet table only if needed. --- search/reverse_geocoder.cpp | 2 +- search/v2/mwm_context.cpp | 6 +++--- search/v2/mwm_context.hpp | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/search/reverse_geocoder.cpp b/search/reverse_geocoder.cpp index 450c2a14de..02a079c450 100644 --- a/search/reverse_geocoder.cpp +++ b/search/reverse_geocoder.cpp @@ -50,7 +50,7 @@ void ReverseGeocoder::GetNearbyStreets(MwmSet::MwmId const & id, m2::PointD cons MwmSet::MwmHandle mwmHandle = m_index.GetMwmHandleById(id); if (mwmHandle.IsAlive()) { - search::v2::MwmContext(move(mwmHandle)).ForEachFeature(rect, addStreet); + search::v2::MwmContext(move(mwmHandle), false).ForEachFeature(rect, addStreet); sort(streets.begin(), streets.end(), my::CompareBy(&Street::m_distanceMeters)); } } diff --git a/search/v2/mwm_context.cpp b/search/v2/mwm_context.cpp index fabc695d0c..3c58d67732 100644 --- a/search/v2/mwm_context.cpp +++ b/search/v2/mwm_context.cpp @@ -13,14 +13,14 @@ void CoverRect(m2::RectD const & rect, int scale, covering::IntervalsT & result) result.insert(result.end(), intervals.begin(), intervals.end()); } -MwmContext::MwmContext(MwmSet::MwmHandle handle) +MwmContext::MwmContext(MwmSet::MwmHandle handle, bool loadH2STable/* = true*/) : m_handle(move(handle)) , m_value(*m_handle.GetValue()) , m_vector(m_value.m_cont, m_value.GetHeader(), m_value.m_table) , m_index(m_value.m_cont.GetReader(INDEX_FILE_TAG), m_value.m_factory) - , m_houseToStreetTable(HouseToStreetTable::Load(m_value)) { - ASSERT(m_houseToStreetTable, ()); + if (loadH2STable) + m_houseToStreetTable = HouseToStreetTable::Load(m_value); } bool MwmContext::GetFeature(uint32_t index, FeatureType & ft) const diff --git a/search/v2/mwm_context.hpp b/search/v2/mwm_context.hpp index 58ff43cd0c..fb92c5c958 100644 --- a/search/v2/mwm_context.hpp +++ b/search/v2/mwm_context.hpp @@ -23,7 +23,8 @@ void CoverRect(m2::RectD const & rect, int scale, covering::IntervalsT & result) /// Now it duplicates "Index" functionality. struct MwmContext { - explicit MwmContext(MwmSet::MwmHandle handle); + /// @todo Split this component on more generic/lightweight. + MwmContext(MwmSet::MwmHandle handle, bool loadH2STable = true); MwmSet::MwmHandle m_handle; MwmValue & m_value;