Skip to content

Commit f7094e3

Browse files
committed
perf: Improve performance during links deduplication
1 parent 49b26bb commit f7094e3

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/lib.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -288,17 +288,9 @@ impl<'a> CSSInliner<'a> {
288288
let mut links = document
289289
.select("link[rel~=stylesheet]")
290290
.map_err(|_| error::InlineError::ParseError(Cow::from("Unknown error")))?
291-
.map(|link_tag| {
292-
link_tag
293-
.attributes
294-
.borrow()
295-
.get("href")
296-
.as_ref()
297-
.unwrap_or_else(|| &"")
298-
.to_string()
299-
})
291+
.filter_map(|link_tag| link_tag.attributes.borrow().get("href").map(str::to_string))
300292
.collect::<Vec<String>>();
301-
links.sort();
293+
links.sort_unstable();
302294
links.dedup();
303295
for href in &links {
304296
if !href.is_empty() {

0 commit comments

Comments
 (0)