From b4d57fad501b83265e17a1a09a7994e802f0352e Mon Sep 17 00:00:00 2001 From: vng Date: Wed, 26 Oct 2011 13:10:54 +0300 Subject: [PATCH] Don't make additional read of mwm header in app startup. --- indexer/mwm_set.cpp | 4 +++- indexer/mwm_set.hpp | 11 +++++++++-- map/feature_vec_model.cpp | 4 +++- map/feature_vec_model.hpp | 2 -- map/framework.cpp | 7 +------ 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/indexer/mwm_set.cpp b/indexer/mwm_set.cpp index 4a81891ee9..7e87f77627 100644 --- a/indexer/mwm_set.cpp +++ b/indexer/mwm_set.cpp @@ -108,7 +108,7 @@ string MwmSet::MwmLock::GetCountryName() const return src.substr(0, src.size() - strlen(DATA_FILE_EXTENSION)); } -bool MwmSet::Add(string const & fileName) +bool MwmSet::Add(string const & fileName, m2::RectD & r) { threads::MutexGuard mutexGuard(m_lock); UNUSED_VALUE(mutexGuard); @@ -124,6 +124,8 @@ bool MwmSet::Add(string const & fileName) GetInfo(fileName, m_info[id]); m_info[id].m_lockCount = 0; m_info[id].m_status = MwmInfo::STATUS_ACTIVE; + + r = m_info[id].m_limitRect; return true; } diff --git a/indexer/mwm_set.hpp b/indexer/mwm_set.hpp index bb0a81272e..ded539a3fa 100644 --- a/indexer/mwm_set.hpp +++ b/indexer/mwm_set.hpp @@ -56,8 +56,15 @@ public: MwmValueBase * m_pValue; }; - // Add new mwm. Returns false, if mwm with given fileName already exists. - bool Add(string const & fileName); + /// Add new mwm. Returns false, if mwm with given fileName already exists. + /// @param[in] fileName File name (without full path) of country. + /// @param[out] r Limit rect of country. + bool Add(string const & fileName, m2::RectD & r); + inline bool Add(string const & fileName) + { + m2::RectD dummy; + return Add(fileName, dummy); + } // Remove mwm. void Remove(string const & fileName); diff --git a/map/feature_vec_model.cpp b/map/feature_vec_model.cpp index abe255b162..a3c00e56a6 100644 --- a/map/feature_vec_model.cpp +++ b/map/feature_vec_model.cpp @@ -42,7 +42,9 @@ void FeaturesFetcher::AddMap(string const & file) { try { - m_multiIndex.Add(file); + m2::RectD r; + m_multiIndex.Add(file, r); + m_rect.Add(r); } catch (Reader::Exception const & e) { diff --git a/map/feature_vec_model.hpp b/map/feature_vec_model.hpp index da62411b48..fcbf5136e6 100644 --- a/map/feature_vec_model.hpp +++ b/map/feature_vec_model.hpp @@ -62,8 +62,6 @@ namespace model //@} index_t const & GetIndex() const { return m_multiIndex; } - - void AddWorldRect(m2::RectD const & r) { m_rect.Add(r); } m2::RectD GetWorldRect() const; }; } diff --git a/map/framework.cpp b/map/framework.cpp index 971735c195..63827a40e1 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -17,7 +17,6 @@ #include "../indexer/feature.hpp" #include "../indexer/scales.hpp" #include "../indexer/drawing_rules.hpp" -#include "../indexer/data_factory.hpp" #include "../base/math.hpp" #include "../base/string_utils.hpp" @@ -42,12 +41,8 @@ template void Framework::AddMap(string const & file) { LOG(LDEBUG, ("Loading map:", file)); + threads::MutexGuard lock(m_modelSyn); - - feature::DataHeader h; - LoadMapHeader(GetPlatform().GetReader(file), h); - - m_model.AddWorldRect(h.GetBounds()); m_model.AddMap(file); }