From bb36271ae5e9582a9056ce36ac2085366d8a74f9 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 19 Jan 2012 20:53:15 +0000 Subject: [PATCH] HighlighterGroup: use idvaluemap::complete_id_if in complete_group_id --- src/highlighter_group.cc | 9 +++++++++ src/highlighter_group.hh | 13 +------------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/highlighter_group.cc b/src/highlighter_group.cc index 831c9b47..7c7e8411 100644 --- a/src/highlighter_group.cc +++ b/src/highlighter_group.cc @@ -44,4 +44,13 @@ CandidateList HighlighterGroup::complete_id(const std::string& prefix, return m_highlighters.complete_id(prefix, cursor_pos); } +CandidateList HighlighterGroup::complete_group_id(const std::string& prefix, + size_t cursor_pos) +{ + return m_highlighters.complete_id_if( + prefix, cursor_pos, + [](std::pair& func) + { return func.second.target() != nullptr; }); +} + } diff --git a/src/highlighter_group.hh b/src/highlighter_group.hh index 07379a63..1157a48c 100644 --- a/src/highlighter_group.hh +++ b/src/highlighter_group.hh @@ -21,18 +21,7 @@ public: HighlighterGroup& get_group(const std::string& id); CandidateList complete_id(const std::string& prefix, size_t cursor_pos); - - CandidateList complete_group_id(const std::string& prefix, size_t cursor_pos) - { - CandidateList all = complete_id(prefix, cursor_pos); - CandidateList res; - for (auto& id : all) - { - if (m_highlighters.find(id)->second.target()) - res.push_back(id); - } - return res; - } + CandidateList complete_group_id(const std::string& prefix, size_t cursor_pos); private: idvaluemap m_highlighters;