LibRegex: Do not return an Optional from Regex::Matcher::execute

The code path that could return an optional no longer exists as of
commit: a962ee020a
This commit is contained in:
Timothy Flynn 2022-02-05 09:24:26 -05:00 committed by Ali Mohammad Pur
parent 27d3de1f17
commit 3729fd06fa
2 changed files with 9 additions and 14 deletions

View file

@ -216,14 +216,12 @@ RegexResult Matcher<Parser>::match(Vector<RegexStringView> const& views, Optiona
auto success = execute(input, state, temp_operations);
// This success is acceptable only if it doesn't read anything from the input (input length is 0).
if (state.string_position <= view_index) {
if (success.has_value() && success.value()) {
operations = temp_operations;
if (!match_count) {
// Nothing was *actually* matched, so append an empty match.
append_match(input, state, view_index);
++match_count;
}
if (success && (state.string_position <= view_index)) {
operations = temp_operations;
if (!match_count) {
// Nothing was *actually* matched, so append an empty match.
append_match(input, state, view_index);
++match_count;
}
}
}
@ -251,10 +249,7 @@ RegexResult Matcher<Parser>::match(Vector<RegexStringView> const& views, Optiona
state.repetition_marks.clear();
auto success = execute(input, state, operations);
if (!success.has_value())
return { false, 0, {}, {}, {}, operations };
if (success.value()) {
if (success) {
succeeded = true;
if (input.regex_options.has_flag_set(AllFlags::MatchNotEndOfLine) && state.string_position == input.view.length()) {
@ -417,7 +412,7 @@ private:
};
template<class Parser>
Optional<bool> Matcher<Parser>::execute(MatchInput const& input, MatchState& state, size_t& operations) const
bool Matcher<Parser>::execute(MatchInput const& input, MatchState& state, size_t& operations) const
{
BumpAllocatedLinkedList<MatchState> states_to_try_next;
size_t recursion_level = 0;

View file

@ -74,7 +74,7 @@ public:
}
private:
Optional<bool> execute(MatchInput const& input, MatchState& state, size_t& operations) const;
bool execute(MatchInput const& input, MatchState& state, size_t& operations) const;
Regex<Parser> const* m_pattern;
typename ParserTraits<Parser>::OptionsType const m_regex_options;