Warning fix in ranked_match.cc
This commit is contained in:
parent
192ea9a9d9
commit
9d09d14d99
|
@ -77,12 +77,11 @@ static bool smartcase_eq(Codepoint query, Codepoint candidate)
|
||||||
|
|
||||||
struct SubseqRes
|
struct SubseqRes
|
||||||
{
|
{
|
||||||
bool matches;
|
|
||||||
int max_index;
|
int max_index;
|
||||||
bool single_word;
|
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;
|
bool single_word = true;
|
||||||
int max_index = -1;
|
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();)
|
for (auto subseq_it = subseq.begin(); subseq_it != subseq.end();)
|
||||||
{
|
{
|
||||||
if (it == str.end())
|
if (it == str.end())
|
||||||
return { false };
|
return {};
|
||||||
const Codepoint c = utf8::read_codepoint(subseq_it, subseq.end());
|
const Codepoint c = utf8::read_codepoint(subseq_it, subseq.end());
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
@ -104,11 +103,11 @@ static SubseqRes subsequence_match_smart_case(StringView str, StringView subseq)
|
||||||
|
|
||||||
++index;
|
++index;
|
||||||
if (it == str.end())
|
if (it == str.end())
|
||||||
return { false };
|
return {};
|
||||||
}
|
}
|
||||||
max_index = index++;
|
max_index = index++;
|
||||||
}
|
}
|
||||||
return { true, max_index, single_word };
|
return SubseqRes{max_index, single_word};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TestFunc>
|
template<typename TestFunc>
|
||||||
|
@ -127,13 +126,13 @@ RankedMatch::RankedMatch(StringView candidate, StringView query, TestFunc func)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto res = subsequence_match_smart_case(candidate, query);
|
auto res = subsequence_match_smart_case(candidate, query);
|
||||||
if (not res.matches)
|
if (not res)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_candidate = candidate;
|
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;
|
m_flags |= Flags::SingleWord;
|
||||||
if (smartcase_eq(query[0], candidate[0]))
|
if (smartcase_eq(query[0], candidate[0]))
|
||||||
m_flags |= Flags::FirstCharMatch;
|
m_flags |= Flags::FirstCharMatch;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user