diff --git a/Userland/Libraries/LibRegex/RegexMatcher.cpp b/Userland/Libraries/LibRegex/RegexMatcher.cpp index a1f3dfe4d5..a1df73503d 100644 --- a/Userland/Libraries/LibRegex/RegexMatcher.cpp +++ b/Userland/Libraries/LibRegex/RegexMatcher.cpp @@ -216,14 +216,12 @@ RegexResult Matcher::match(Vector 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::match(Vector 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 -Optional Matcher::execute(MatchInput const& input, MatchState& state, size_t& operations) const +bool Matcher::execute(MatchInput const& input, MatchState& state, size_t& operations) const { BumpAllocatedLinkedList states_to_try_next; size_t recursion_level = 0; diff --git a/Userland/Libraries/LibRegex/RegexMatcher.h b/Userland/Libraries/LibRegex/RegexMatcher.h index f9a433145a..4f4e875ed5 100644 --- a/Userland/Libraries/LibRegex/RegexMatcher.h +++ b/Userland/Libraries/LibRegex/RegexMatcher.h @@ -74,7 +74,7 @@ public: } private: - Optional execute(MatchInput const& input, MatchState& state, size_t& operations) const; + bool execute(MatchInput const& input, MatchState& state, size_t& operations) const; Regex const* m_pattern; typename ParserTraits::OptionsType const m_regex_options;