From 9d09d14d997e2d0dbca6bce5e4fe9ab2c3d25a85 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 30 Jan 2017 11:22:14 +0000 Subject: [PATCH] Warning fix in ranked_match.cc --- src/ranked_match.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/ranked_match.cc b/src/ranked_match.cc index ad7e4cec..34d38351 100644 --- a/src/ranked_match.cc +++ b/src/ranked_match.cc @@ -77,12 +77,11 @@ static bool smartcase_eq(Codepoint query, Codepoint candidate) struct SubseqRes { - bool matches; int max_index; bool single_word; }; -static SubseqRes subsequence_match_smart_case(StringView str, StringView subseq) +static Optional subsequence_match_smart_case(StringView str, StringView subseq) { bool single_word = true; int max_index = -1; @@ -91,7 +90,7 @@ static SubseqRes subsequence_match_smart_case(StringView str, StringView subseq) for (auto subseq_it = subseq.begin(); subseq_it != subseq.end();) { if (it == str.end()) - return { false }; + return {}; const Codepoint c = utf8::read_codepoint(subseq_it, subseq.end()); while (true) { @@ -104,11 +103,11 @@ static SubseqRes subsequence_match_smart_case(StringView str, StringView subseq) ++index; if (it == str.end()) - return { false }; + return {}; } max_index = index++; } - return { true, max_index, single_word }; + return SubseqRes{max_index, single_word}; } template @@ -127,13 +126,13 @@ RankedMatch::RankedMatch(StringView candidate, StringView query, TestFunc func) return; auto res = subsequence_match_smart_case(candidate, query); - if (not res.matches) + if (not res) return; m_candidate = candidate; - m_max_index = res.max_index; + m_max_index = res->max_index; - if (res.single_word) + if (res->single_word) m_flags |= Flags::SingleWord; if (smartcase_eq(query[0], candidate[0])) m_flags |= Flags::FirstCharMatch;