summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2023-11-15 12:46:28 +1100
committerMaxime Coste <mawww@kakoune.org>2023-11-15 12:46:28 +1100
commit1cfe5273f348a9a55cf1ee671463d0186b0edb4d (patch)
treeedc66088c0b1fdfde8bfa387c60ee2ed03f6ba25 /src
parent4a1a3ee06e9df1af5b2b6f6627200f92e64fe515 (diff)
Do not use range adaptor to gather ranked matches
This ends up constructing RankedMatch twice, once when computing the number of elements then once when actually filling the vector.
Diffstat (limited to 'src')
-rw-r--r--src/commands.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/commands.cc b/src/commands.cc
index 55becf4a..1c6ea09a 100644
--- a/src/commands.cc
+++ b/src/commands.cc
@@ -336,9 +336,12 @@ private:
Completions rank_candidates(StringView query)
{
UsedLetters query_letters = used_letters(query);
- auto matches = m_candidates | transform([&](const auto& c) { return RankedMatch{c.first, c.second, query, query_letters}; })
- | filter([](const auto& m) { return (bool)m; })
- | gather<Vector<RankedMatch>>();
+ Vector<RankedMatch> matches;
+ for (auto&& candidate : m_candidates)
+ {
+ if (RankedMatch m{candidate.first, candidate.second, query, query_letters})
+ matches.push_back(m);
+ }
constexpr size_t max_count = 100;
CandidateList res;