LibRegex: Remove unused "simple substring search" optimization
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

This is not relevant for LibJS since it only works when the input is
UTF-8, and LibJS always provides UTF-16.
This commit is contained in:
Andreas Kling 2025-04-15 18:18:32 +02:00 committed by Andreas Kling
parent 0c93a07fb1
commit ca2f0141f6
Notes: github-actions[bot] 2025-04-16 08:05:47 +00:00
2 changed files with 0 additions and 30 deletions

View file

@ -45,16 +45,6 @@ public:
RegexStringView(String&&) = delete;
bool is_string_view() const
{
return m_view.has<StringView>();
}
StringView string_view() const
{
return m_view.get<StringView>();
}
Utf16View const& u16_view() const
{
return m_view.get<Utf16View>();

View file

@ -454,26 +454,6 @@ private:
template<class Parser>
bool Matcher<Parser>::execute(MatchInput const& input, MatchState& state, size_t& operations) const
{
if (m_pattern->parser_result.optimization_data.pure_substring_search.has_value() && input.view.is_string_view()) {
// Yay, we can do a simple substring search!
auto& needle = m_pattern->parser_result.optimization_data.pure_substring_search.value();
if (needle.length() + state.string_position > input.view.length())
return false;
auto haystack = input.view.string_view().substring_view(state.string_position);
if (input.regex_options.has_flag_set(AllFlags::Insensitive)) {
if (!haystack.substring_view(0, needle.length()).equals_ignoring_ascii_case(needle))
return false;
} else {
if (!haystack.starts_with(needle))
return false;
}
state.string_position += needle.length();
state.string_position_in_code_units += needle.length();
return true;
}
BumpAllocatedLinkedList<MatchState> states_to_try_next;
HashTable<u64> seen_state_hashes;
#if REGEX_DEBUG