From c8325d4b968c95ae75f160f7b294903667bd5cd8 Mon Sep 17 00:00:00 2001 From: vng Date: Wed, 12 Oct 2011 15:51:26 +0300 Subject: [PATCH] Calculate coastline type value for once. It's use very often. --- indexer/classificator.cpp | 9 +++------ indexer/classificator.hpp | 5 +++-- indexer/feature_visibility.cpp | 3 +-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/indexer/classificator.cpp b/indexer/classificator.cpp index d3b91fe2b1..17169eb220 100644 --- a/indexer/classificator.cpp +++ b/indexer/classificator.cpp @@ -438,6 +438,9 @@ void Classificator::ReadClassificator(string const & buffer) tree::LoadTreeAsText(iss, policy); m_root.Sort(); + + char const * path[] = { "natural", "coastline" }; + m_coastType = GetTypeByPath(vector(path, path + 2)); } void Classificator::PrintClassificator(char const * fPath) @@ -500,12 +503,6 @@ uint32_t Classificator::GetTypeByPath(vector const & path) const return type; } -uint32_t Classificator::GetCoastType() const -{ - char const * path[] = { "natural", "coastline" }; - return GetTypeByPath(vector(path, path + 2)); -} - void Classificator::ReadTypesMapping(string const & buffer) { m_i2t.Load(buffer); diff --git a/indexer/classificator.hpp b/indexer/classificator.hpp index 37e2c95c5d..8d22c5eb50 100644 --- a/indexer/classificator.hpp +++ b/indexer/classificator.hpp @@ -199,6 +199,8 @@ class Classificator Index2Type m_i2t; Type2Index m_t2i; + uint32_t m_coastType; + static ClassifObject * AddV(ClassifObject * parent, string const & key, string const & value); public: @@ -226,7 +228,7 @@ public: uint32_t GetIndexForType(uint32_t t) const { return m_t2i.GetIndex(t); } uint32_t GetTypeForIndex(uint32_t i) const { return m_i2t.GetType(i); } - uint32_t GetCoastType() const; + inline uint32_t GetCoastType() const { return m_coastType; } // Iterate for possible objects types //template void ForEachType(ToDo toDo) @@ -240,7 +242,6 @@ public: ClassifObject * GetMutableRoot() { return &m_root; } //@} -public: /// @name Used only in feature_visibility.cpp, not for public use. //@{ template typename ToDo::ResultType diff --git a/indexer/feature_visibility.cpp b/indexer/feature_visibility.cpp index 6d7b816f04..4a3be0560e 100644 --- a/indexer/feature_visibility.cpp +++ b/indexer/feature_visibility.cpp @@ -243,12 +243,11 @@ bool IsDrawableLike(vector const & types, FeatureGeoType ft) bool IsDrawableForIndex(FeatureBase const & f, int level) { Classificator const & c = classif(); - static uint32_t const coastType = c.GetCoastType(); FeatureBase::GetTypesFn types; f.ForEachTypeRef(types); - if (f.GetFeatureType() == feature::GEOM_AREA && !types.Has(coastType)) + if (f.GetFeatureType() == feature::GEOM_AREA && !types.Has(c.GetCoastType())) if (!scales::IsGoodForLevel(level, f.GetLimitRect())) return false;