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.
This commit is contained in:
Maxime Coste 2023-11-15 12:46:28 +11:00
parent 4a1a3ee06e
commit 1cfe5273f3

View File

@ -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;