diff options
author | Maxim Pimenov <m@maps.me> | 2016-04-26 17:02:16 +0300 |
---|---|---|
committer | Maxim Pimenov <m@maps.me> | 2016-04-26 18:54:48 +0300 |
commit | 9243f3130a86b17f140399d26fe24a5ee124a64f (patch) | |
tree | 60ba1c5f803a7073de27eb73ca1045b304466dce /base | |
parent | 360bafbc2907788a3893792fb6dd366d3eb48e44 (diff) |
Review fixes.
Diffstat (limited to 'base')
-rw-r--r-- | base/mem_trie.hpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/base/mem_trie.hpp b/base/mem_trie.hpp index 4953cecd02..a37ed25e0e 100644 --- a/base/mem_trie.hpp +++ b/base/mem_trie.hpp @@ -33,15 +33,15 @@ public: void ForEach(ToDo && toDo) { TString prefix; - ForEach(&m_root, prefix, toDo); + ForEach(&m_root, prefix, forward<ToDo>(toDo)); } template <typename ToDo> - void ForEachInSubtree(TString prefix, ToDo && toDo) + void ForEachInSubtree(TString prefix, ToDo && toDo) const { - Node * nd = MoveTo(prefix); - if (nd) - ForEach(nd, prefix, toDo); + Node const * node = MoveTo(prefix); + if (node) + ForEach(node, prefix, forward<ToDo>(toDo)); } size_t GetNumNodes() const { return m_numNodes; } @@ -79,22 +79,21 @@ private: DISALLOW_COPY_AND_MOVE(Node); }; - Node * MoveTo(TString const & key) + Node const * MoveTo(TString const & key) const { - Node * cur = &m_root; + Node const * cur = &m_root; for (auto const & c : key) { auto const it = cur->m_moves.find(c); - if (it != cur->m_moves.end()) - cur = it->second; - else + if (it == cur->m_moves.end()) return nullptr; + cur = it->second; } return cur; } template <typename ToDo> - void ForEach(Node * root, TString & prefix, ToDo && toDo) + void ForEach(Node const * root, TString & prefix, ToDo && toDo) const { if (!root->m_values.empty()) { |