From e31dbea01ca49487c59623ca4ed802c42bc71f1f Mon Sep 17 00:00:00 2001 From: Leynos Date: Thu, 11 Sep 2025 13:06:46 +0100 Subject: [PATCH 1/2] Restore Cargo.lock --- src/html.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/html.rs b/src/html.rs index f495c185..52c18a8e 100644 --- a/src/html.rs +++ b/src/html.rs @@ -33,11 +33,10 @@ fn node_text(handle: &Handle) -> String { } fn is_ignored_tag(tag: &str) -> bool { - tag.eq_ignore_ascii_case("script") - || tag.eq_ignore_ascii_case("style") - || tag.eq_ignore_ascii_case("noscript") - || tag.eq_ignore_ascii_case("template") - || tag.eq_ignore_ascii_case("head") + matches!( + tag.to_ascii_lowercase().as_str(), + "script" | "style" | "noscript" | "template" | "head" + ) } /// Recursively appends text nodes from `handle` to `out`, tracking whether the @@ -109,7 +108,7 @@ fn collect_rows(handle: &Handle, rows: &mut Vec) { } fn is_bold_tag(tag: &str) -> bool { - tag.eq_ignore_ascii_case("strong") || tag.eq_ignore_ascii_case("b") + matches!(tag.to_ascii_lowercase().as_str(), "strong" | "b") } /// Returns `true` if `handle` contains a `` or `` descendant. From b7ae94296570e765e3c11d229e38e33e829873cd Mon Sep 17 00:00:00 2001 From: Leynos Date: Sat, 13 Sep 2025 15:15:16 +0100 Subject: [PATCH 2/2] Avoid allocation in HTML tag checks --- src/html.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/html.rs b/src/html.rs index 52c18a8e..8baa3728 100644 --- a/src/html.rs +++ b/src/html.rs @@ -34,8 +34,12 @@ fn node_text(handle: &Handle) -> String { fn is_ignored_tag(tag: &str) -> bool { matches!( - tag.to_ascii_lowercase().as_str(), - "script" | "style" | "noscript" | "template" | "head" + tag, + t if t.eq_ignore_ascii_case("script") + || t.eq_ignore_ascii_case("style") + || t.eq_ignore_ascii_case("noscript") + || t.eq_ignore_ascii_case("template") + || t.eq_ignore_ascii_case("head") ) } @@ -108,7 +112,10 @@ fn collect_rows(handle: &Handle, rows: &mut Vec) { } fn is_bold_tag(tag: &str) -> bool { - matches!(tag.to_ascii_lowercase().as_str(), "strong" | "b") + matches!( + tag, + t if t.eq_ignore_ascii_case("strong") || t.eq_ignore_ascii_case("b") + ) } /// Returns `true` if `handle` contains a `` or `` descendant.