diff options
author | rachytski <siarhei.rachytski@gmail.com> | 2012-01-31 16:25:39 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:32:50 +0300 |
commit | 6f1fcf17bd298ae8168219c6ff4d25efa7436096 (patch) | |
tree | 7034bef2ee0bca7b408f138f847db362224dcb31 /indexer/drawing_rules.cpp | |
parent | 2a241f345d8e0defe7f129aff5745289055e8719 (diff) |
Resizing BaseRule id caches at startup. Closes #334
Diffstat (limited to 'indexer/drawing_rules.cpp')
-rw-r--r-- | indexer/drawing_rules.cpp | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/indexer/drawing_rules.cpp b/indexer/drawing_rules.cpp index 684b8b8be7..f641353953 100644 --- a/indexer/drawing_rules.cpp +++ b/indexer/drawing_rules.cpp @@ -13,6 +13,94 @@ namespace drule { +BaseRule::BaseRule() : m_type(node | way) +{} + +BaseRule::~BaseRule() +{} + +void BaseRule::CheckCacheSize(size_t s) +{ + m_id1.resize(s); + MakeEmptyID(); + + m_id2.resize(s); + MakeEmptyID2(); +} + +uint32_t BaseRule::GetID(size_t threadID) const +{ + ASSERT(m_id1.size() > threadID, ()); + return m_id1[threadID]; +} + +void BaseRule::SetID(size_t threadID, uint32_t id) const +{ + ASSERT(m_id1.size() > threadID, ()); + m_id1[threadID] = id; +} + +void BaseRule::MakeEmptyID(size_t threadID) +{ + ASSERT(m_id1.size() > threadID, ()); + m_id1[threadID] = empty_id; +} + +void BaseRule::MakeEmptyID() +{ + for (size_t i = 0; i < m_id1.size(); ++i) + MakeEmptyID(i); +} + +uint32_t BaseRule::GetID2(size_t threadID) const +{ + ASSERT(m_id2.size() > threadID, ()); + return m_id2[threadID]; +} + +void BaseRule::SetID2(size_t threadID, uint32_t id) const +{ + ASSERT(m_id2.size() > threadID, ()); + m_id2[threadID] = id; +} + +void BaseRule::MakeEmptyID2(size_t threadID) +{ + ASSERT(m_id2.size() > threadID, ()); + m_id2[threadID] = empty_id; +} + +void BaseRule::MakeEmptyID2() +{ + for (size_t i = 0; i < m_id2.size(); ++i) + MakeEmptyID2(i); +} + +LineDefProto const * BaseRule::GetLine() const +{ + return 0; +} + +AreaRuleProto const * BaseRule::GetArea() const +{ + return 0; +} + +SymbolRuleProto const * BaseRule::GetSymbol() const +{ + return 0; +} + +CaptionDefProto const * BaseRule::GetCaption(int) const +{ + return 0; +} + +CircleRuleProto const * BaseRule::GetCircle() const +{ + return 0; +} + RulesHolder::~RulesHolder() { Clean(); @@ -66,6 +154,11 @@ void RulesHolder::ClearCaches() ForEachRule(bind(&BaseRule::MakeEmptyID2, _4)); } +void RulesHolder::ResizeCaches(size_t s) +{ + ForEachRule(bind(&BaseRule::CheckCacheSize, _4, s)); +} + RulesHolder & rules() { static RulesHolder holder; |