markdown: Use the faster hasher (#38469)

Micro-optimisation in the markdown crate to use the faster hasher.

Release Notes:

- N/A
This commit is contained in:
Nia
2025-09-19 01:51:41 +00:00
committed by GitHub
parent e5e308ba78
commit c826ce6fc6
5 changed files with 25 additions and 18 deletions
+19 -13
View File
@@ -4,7 +4,9 @@ pub use pulldown_cmark::TagEnd as MarkdownTagEnd;
use pulldown_cmark::{
Alignment, CowStr, HeadingLevel, LinkType, MetadataBlockKind, Options, Parser,
};
use std::{collections::HashSet, ops::Range, path::Path, sync::Arc};
use std::{ops::Range, path::Path, sync::Arc};
use collections::HashSet;
use crate::path_range::PathWithRange;
@@ -26,8 +28,8 @@ pub fn parse_markdown(
HashSet<Arc<Path>>,
) {
let mut events = Vec::new();
let mut language_names = HashSet::new();
let mut language_paths = HashSet::new();
let mut language_names = HashSet::default();
let mut language_paths = HashSet::default();
let mut within_link = false;
let mut within_metadata = false;
let mut parser = Parser::new_ext(text, PARSE_OPTIONS)
@@ -579,8 +581,8 @@ mod tests {
(30..37, Text),
(30..37, End(MarkdownTagEnd::Paragraph))
],
HashSet::new(),
HashSet::new()
HashSet::default(),
HashSet::default()
)
)
}
@@ -613,8 +615,8 @@ mod tests {
(46..51, Text),
(0..51, End(MarkdownTagEnd::Paragraph))
],
HashSet::new(),
HashSet::new()
HashSet::default(),
HashSet::default()
)
);
}
@@ -670,8 +672,8 @@ mod tests {
(43..53, SubstitutedText("–––––".into())),
(0..53, End(MarkdownTagEnd::Paragraph))
],
HashSet::new(),
HashSet::new()
HashSet::default(),
HashSet::default()
)
)
}
@@ -695,8 +697,12 @@ mod tests {
(8..34, Text),
(0..37, End(MarkdownTagEnd::CodeBlock)),
],
HashSet::from(["rust".into()]),
HashSet::new()
{
let mut h = HashSet::default();
h.insert("rust".into());
h
},
HashSet::default()
)
);
assert_eq!(
@@ -716,8 +722,8 @@ mod tests {
(4..16, Text),
(4..16, End(MarkdownTagEnd::CodeBlock))
],
HashSet::new(),
HashSet::new()
HashSet::default(),
HashSet::default()
)
);
}