Skip to content

Commit baea2c1

Browse files
committed
perf: do not overallocate
1 parent cf96421 commit baea2c1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

css-inline/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ fn merge_styles(
422422
let mut final_styles: Vec<String> = Vec::new();
423423
for declaration in declarations {
424424
let (name, value) = declaration?;
425-
let mut style = String::with_capacity(256);
425+
// Allocate enough space for the new style
426+
let mut style = String::with_capacity(name.len() + value.len() + 2);
426427
style.push_str(&name);
427428
style.push_str(": ");
428429
replace_double_quotes!(style, name, value.trim());

0 commit comments

Comments
 (0)