Skip to content

Commit 9a04ae6

Browse files
committed
perf: more in-place sorting
1 parent 0863d46 commit 9a04ae6

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

css-inline/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,12 @@ impl<'a> CSSInliner<'a> {
255255
} else {
256256
continue;
257257
};
258+
styles.sort_unstable_by(|_, (a, _), _, (b, _)| a.cmp(b));
258259
let attributes = &mut element.attributes;
259260
if let Some(existing_style) = attributes.get_style_mut() {
260-
styles.sort_unstable_by(|_, (a, _), _, (b, _)| a.cmp(b));
261261
merge_styles(existing_style, styles)?;
262262
} else {
263263
let mut final_styles = String::with_capacity(128);
264-
let mut styles = styles.iter().collect::<Vec<_>>();
265-
styles.sort_unstable_by(|(_, (a, _)), (_, (b, _))| a.cmp(b));
266264
for (name, (_, value)) in styles {
267265
final_styles.push_str(name.as_str());
268266
final_styles.push(':');

0 commit comments

Comments
 (0)