Replace lazy hashset with matches!
* Replace lazy hashset with matches!
llvm will typically create much faster code than accessing a hashset at
runtime
source: trust me bro
* cargo fix
* cargo fmt
* shorten docstring
-use std::collections::HashSet;
-
use crate::types::{uri::raw::RawUri, FileType, InputContent};
mod html5ever;
@@ -8,26 +6,16 @@ mod markdown;
mod plaintext;
use markdown::extract_markdown;
-use once_cell::sync::Lazy;
use plaintext::extract_plaintext;
-/// HTML elements that are deemed verbatim (i.e. preformatted).
+/// Check if the given element is in the list of preformatted ("verbatim") tags.
+///
/// These will be excluded from link checking by default.
-static VERBATIM_ELEMENTS: Lazy<HashSet<String>> = Lazy::new(|| {
- HashSet::from_iter([
- "pre".into(),
- "code".into(),
- "textarea".into(),
- "samp".into(),
- "xmp".into(),
- "plaintext".into(),
- "listing".into(),
- ])
-});
-
-/// Check if the given element is in the list of preformatted tags
pub(crate) fn is_verbatim_elem(name: &str) -> bool {
- VERBATIM_ELEMENTS.contains(name)
+ matches!(
+ name,
+ "pre" | "code" | "textarea" | "samp" | "xmp" | "plaintext" | "listing"
+ )
}
/// A handler for extracting links from various input formats like Markdown and
