Truly independent web browser
LibRegex: Find required literal characters with memchr
Andreas Kling85b90d301232
diff --git a/Cargo.lock b/Cargo.lockindex 35edbe0fa34..3f520e0dbfa 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -838,6 +838,7 @@ dependencies = ["cbindgen","ladybird_allocator","libunicode_rust",+ "memchr","rustc-demangle",]diff --git a/Libraries/LibRegex/Rust/Cargo.toml b/Libraries/LibRegex/Rust/Cargo.tomlindex e7dd1db31e0..5d4025cb4b5 100644--- a/Libraries/LibRegex/Rust/Cargo.toml+++ b/Libraries/LibRegex/Rust/Cargo.toml@@ -12,6 +12,7 @@ crate-type = ["staticlib", "rlib"]ak = { path = "../../../AK/Rust" }ladybird_allocator = { path = "../../RustAllocator", optional = true }libunicode_rust = { path = "../../LibUnicode/Rust", default-features = false }+memchr = "2"rustc-demangle = "0.1"[features]diff --git a/Libraries/LibRegex/Rust/src/vm.rs b/Libraries/LibRegex/Rust/src/vm.rsindex 03c18d00e43..92ba51deb8c 100644--- a/Libraries/LibRegex/Rust/src/vm.rs+++ b/Libraries/LibRegex/Rust/src/vm.rs@@ -136,7 +136,7 @@ impl Input for &[u8] {if byte > 0x7F {return None;}- let offset = self.get(start..end)?.iter().position(|&c| c == byte)?;+ let offset = memchr::memchr(byte, self.get(start..end)?)?;Some(start + offset)}