Replace lazy hashset with matches! (#656)

* 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
This commit is contained in:
Markus Unterwaditzer 2022-06-18 19:00:07 +02:00 committed by GitHub
parent 17a6db64b2
commit f1ae22da09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,3 @@
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