mirror of
https://github.com/Hopiu/lychee.git
synced 2026-04-05 05:51:00 +00:00
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:
parent
17a6db64b2
commit
f1ae22da09
1 changed files with 6 additions and 18 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue