diff options
author | Maxim Pimenov <m@maps.me> | 2017-02-13 18:59:55 +0300 |
---|---|---|
committer | Maxim Pimenov <m@maps.me> | 2017-02-13 19:10:37 +0300 |
commit | a1f4ac5953e858dc4199a54e0eef81fde41ffaa2 (patch) | |
tree | f7502be8382d695d091896882339f724a8256150 /indexer/categories_holder.hpp | |
parent | 5ddc8db2baa8f158f5ed84c09af550f52e50a1ce (diff) |
[indexer] United all tries-by-locale into one trie.
Diffstat (limited to 'indexer/categories_holder.hpp')
-rw-r--r-- | indexer/categories_holder.hpp | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/indexer/categories_holder.hpp b/indexer/categories_holder.hpp index b40982e001..95050ca09e 100644 --- a/indexer/categories_holder.hpp +++ b/indexer/categories_holder.hpp @@ -56,7 +56,8 @@ private: Type2CategoryCont m_type2cat; // Maps locale and category token to the list of corresponding types. - map<int8_t, unique_ptr<Trie>> m_name2type; + // Locale is treated as a special symbol prepended to the token. + unique_ptr<Trie> m_name2type; GroupTranslations m_groupTranslations; @@ -109,10 +110,9 @@ public: template <class ToDo> void ForEachTypeByName(int8_t locale, String const & name, ToDo && toDo) const { - auto const it = m_name2type.find(locale); - if (it == m_name2type.end()) - return; - it->second->ForEachInNode(name, my::MakeIgnoreFirstArgument(forward<ToDo>(toDo))); + auto const localePrefix = String(1, static_cast<strings::UniChar>(locale)); + m_name2type->ForEachInNode(localePrefix + name, + my::MakeIgnoreFirstArgument(forward<ToDo>(toDo))); } inline GroupTranslations const & GetGroupTranslations() const { return m_groupTranslations; } @@ -126,14 +126,7 @@ public: string GetReadableFeatureType(uint32_t type, int8_t locale) const; // Exposes the tries that map category tokens to types. - Trie const * GetNameToTypesTrie(int8_t locale) const - { - auto const it = m_name2type.find(locale); - if (it == m_name2type.end()) - return nullptr; - return it->second.get(); - } - + Trie const & GetNameToTypesTrie() const { return *m_name2type; } bool IsTypeExist(uint32_t type) const; inline void Swap(CategoriesHolder & r) |