summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-01-30 11:22:14 +0000
committerMaxime Coste <mawww@kakoune.org>2017-01-30 11:22:14 +0000
commit9d09d14d997e2d0dbca6bce5e4fe9ab2c3d25a85 (patch)
tree6520a9dfcadf950507c7bc1e9a6a330552caccaf /src
parent192ea9a9d9e914ef9d8c6fe6d69c6c40ef3a6fc4 (diff)
Warning fix in ranked_match.cc
Diffstat (limited to 'src')
-rw-r--r--src/ranked_match.cc15
1 files 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<SubseqRes> 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<typename TestFunc>
@@ -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;