diff --git a/base/mem_trie.hpp b/base/mem_trie.hpp index b4ceabf244..e19a7a71dc 100644 --- a/base/mem_trie.hpp +++ b/base/mem_trie.hpp @@ -12,7 +12,7 @@ namespace my { -template +template class MapMoves { public: @@ -23,7 +23,7 @@ public: toDo(subtree.first, *subtree.second); } - SubTree * GetSubTree(Char const & c) const + Subtree * GetSubtree(Char const & c) const { auto const it = m_subtrees.find(c); if (it == m_subtrees.end()) @@ -31,12 +31,12 @@ public: return it->second.get(); } - SubTree & GetOrCreateSubTree(Char const & c, bool & created) + Subtree & GetOrCreateSubtree(Char const & c, bool & created) { auto & node = m_subtrees[c]; if (!node) { - node = my::make_unique(); + node = my::make_unique(); created = true; } else @@ -49,7 +49,7 @@ public: void Clear() { m_subtrees.clear(); } private: - std::map> m_subtrees; + std::map> m_subtrees; }; template @@ -58,7 +58,7 @@ struct VectorValues template void Add(V && v) { - m_values.push_back(std::forward(v)); + m_values.emplace_back(std::forward(v)); } template @@ -186,7 +186,7 @@ private: Node & GetMove(Char const & c, bool & created) { - return m_moves.GetOrCreateSubTree(c, created); + return m_moves.GetOrCreateSubtree(c, created); } template @@ -212,7 +212,7 @@ private: auto const * cur = &m_root; for (auto const & c : key) { - cur = cur->m_moves.GetSubTree(c); + cur = cur->m_moves.GetSubtree(c); if (!cur) break; } @@ -224,7 +224,8 @@ private: template void ForEachInNode(Node const & node, String const & prefix, ToDo && toDo) const { - node.m_values.ForEach(std::bind(std::forward(toDo), prefix, std::placeholders::_1)); + node.m_values.ForEach( + std::bind(std::forward(toDo), std::ref(prefix), std::placeholders::_1)); } // Calls |toDo| for each key-value pair in subtree where |node| is a diff --git a/indexer/search_string_utils.cpp b/indexer/search_string_utils.cpp index 0503d2a591..eb73e314a0 100644 --- a/indexer/search_string_utils.cpp +++ b/indexer/search_string_utils.cpp @@ -106,8 +106,7 @@ public: template void ForEach(ToDo && toDo) const { - if (m_value) - toDo(m_value); + toDo(m_value); } void Clear() { m_value = false; } @@ -115,7 +114,7 @@ public: bool m_value = false; }; - template + template class Moves { public: @@ -126,7 +125,7 @@ public: toDo(subtree.first, *subtree.second); } - SubTree * GetSubTree(Char const & c) const + Subtree * GetSubtree(Char const & c) const { for (auto const & subtree : m_subtrees) { @@ -136,7 +135,7 @@ public: return nullptr; } - SubTree & GetOrCreateSubTree(Char const & c, bool & created) + Subtree & GetOrCreateSubtree(Char const & c, bool & created) { for (size_t i = 0; i < m_subtrees.size(); ++i) { @@ -148,14 +147,14 @@ public: } created = true; - m_subtrees.emplace_back(c, make_unique()); + m_subtrees.emplace_back(c, make_unique()); return *m_subtrees.back().second; } void Clear() { m_subtrees.clear(); } private: - buffer_vector>, 8> m_subtrees; + buffer_vector>, 8> m_subtrees; }; StreetsSynonymsHolder() @@ -226,16 +225,15 @@ public: for (auto const * s : affics) { UniString const us = NormalizeAndSimplifyString(s); - m_strings.Add(us, true); + m_strings.Add(us, true /* end of string */); } } bool MatchPrefix(UniString const & s) const { bool found = false; - m_strings.ForEachInNode(s, [&](UniString const & prefix, bool value) { + m_strings.ForEachInNode(s, [&](UniString const & prefix, bool /* value */) { ASSERT_EQUAL(s, prefix, ()); - ASSERT(value, ()); found = true; }); return found; @@ -246,7 +244,6 @@ public: bool found = false; m_strings.ForEachInNode(s, [&](UniString const & prefix, bool value) { ASSERT_EQUAL(s, prefix, ()); - ASSERT(value, ()); found = value; }); return found;