diff --git a/indexer/categories_holder.cpp b/indexer/categories_holder.cpp index 51ffd6de4f..4c222c9931 100644 --- a/indexer/categories_holder.cpp +++ b/indexer/categories_holder.cpp @@ -41,7 +41,7 @@ void CategoriesHolder::AddCategory(Category & cat, vector & types) for (size_t i = 0; i < p->m_synonyms.size(); ++i) { - ASSERT(p->m_synonyms[i].m_locale != UNSUPPORTED_LOCALE_CODE, ()); + ASSERT(p->m_synonyms[i].m_locale != kUnsupportedLocaleCode, ()); StringT const uniName = search::NormalizeAndSimplifyString(p->m_synonyms[i].m_name); @@ -128,7 +128,7 @@ void CategoriesHolder::LoadFromStream(istream & s) } int8_t const langCode = MapLocaleToInteger(*iter); - CHECK(langCode != UNSUPPORTED_LOCALE_CODE, ("Invalid language code:", *iter, "at line:", lineNumber)); + CHECK(langCode != kUnsupportedLocaleCode, ("Invalid language code:", *iter, "at line:", lineNumber)); while (++iter) { @@ -148,7 +148,7 @@ void CategoriesHolder::LoadFromStream(istream & s) name.m_name = name.m_name.substr(1); } else - name.m_prefixLengthToSuggest = Category::EMPTY_PREFIX_LENGTH; + name.m_prefixLengthToSuggest = Category::kEmptyPrefixLength; // Process emoji symbols. using namespace strings; @@ -263,5 +263,5 @@ int8_t CategoriesHolder::MapLocaleToInteger(string const & locale) return 17; // Simplified Chinese by default for all other cases } - return UNSUPPORTED_LOCALE_CODE; + return kUnsupportedLocaleCode; } diff --git a/indexer/categories_holder.hpp b/indexer/categories_holder.hpp index feaad857d5..0af32fb181 100644 --- a/indexer/categories_holder.hpp +++ b/indexer/categories_holder.hpp @@ -15,7 +15,7 @@ class CategoriesHolder public: struct Category { - static const uint8_t EMPTY_PREFIX_LENGTH = 10; + static constexpr uint8_t kEmptyPrefixLength = 10; struct Name { @@ -48,14 +48,14 @@ public: void LoadFromStream(istream & s); template - void ForEachCategory(ToDo toDo) const + void ForEachCategory(ToDo && toDo) const { for (IteratorT i = m_type2cat.begin(); i != m_type2cat.end(); ++i) toDo(*i->second); } template - void ForEachName(ToDo toDo) const + void ForEachName(ToDo && toDo) const { for (IteratorT i = m_type2cat.begin(); i != m_type2cat.end(); ++i) for (size_t j = 0; j < i->second->m_synonyms.size(); ++j) @@ -63,7 +63,7 @@ public: } template - void ForEachTypeByName(int8_t locale, StringT const & name, ToDo toDo) const + void ForEachTypeByName(int8_t locale, StringT const & name, ToDo && toDo) const { typedef typename Name2CatContT::const_iterator IterT; @@ -90,7 +90,7 @@ public: /// Converts any language locale from UI to internal integer code static int8_t MapLocaleToInteger(string const & locale); - static int8_t const UNSUPPORTED_LOCALE_CODE = -1; + static constexpr int8_t kUnsupportedLocaleCode = -1; private: void AddCategory(Category & cat, vector & types); diff --git a/search/search_engine.cpp b/search/search_engine.cpp index 7267125a40..2f36a6d8a6 100644 --- a/search/search_engine.cpp +++ b/search/search_engine.cpp @@ -40,7 +40,7 @@ class InitSuggestions public: void operator()(CategoriesHolder::Category::Name const & name) { - if (name.m_prefixLengthToSuggest != CategoriesHolder::Category::EMPTY_PREFIX_LENGTH) + if (name.m_prefixLengthToSuggest != CategoriesHolder::Category::kEmptyPrefixLength) { strings::UniString const uniName = NormalizeAndSimplifyString(name.m_name);