From 25f93c095b1d5090f352a36231f9736084bfb59f Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Tue, 20 Jan 2026 11:08:18 -0500 Subject: [PATCH] Use the matcher instead of the regex directly. This improves pattern parsing performance by about 3x by avoiding regex matching when it's not needed. Previously the EcmaRegexp was recompiling the protocol regex 6 times (once for each scheme that it was trying to match against) --- src/component.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/component.rs b/src/component.rs index ee746c9..92a61d5 100644 --- a/src/component.rs +++ b/src/component.rs @@ -69,11 +69,9 @@ impl Component { pub(crate) fn protocol_component_matches_special_scheme(&self) -> bool { const SPECIAL_SCHEMES: [&str; 6] = ["ftp", "file", "http", "https", "ws", "wss"]; - if let Ok(regex) = &self.regexp { - for scheme in SPECIAL_SCHEMES { - if regex.matches(scheme).is_some() { - return true; - } + for scheme in SPECIAL_SCHEMES { + if self.matcher.matches(scheme).is_some() { + return true; } } false