Skip to content

Commit c94c5dc

Browse files
committed
perf(linter): remove allocation in CompositeFix::merge_fixes (#14090)
`String::shrink_to_fit` will generally reallocate in order to reduce the `String`'s capacity to minimum size. In `merge_fixes`, the size of the `String` is unlikely to be excessively over-sized - in best case, it's exactly the right size, and in worst case it's twice as large than it needs to be. The reallocation probably costs more than the gain of clawing back a few bytes of memory. So remove this operation.
1 parent c796966 commit c94c5dc

File tree

1 file changed

+0
-1
lines changed
  • crates/oxc_linter/src/fixer

1 file changed

+0
-1
lines changed

crates/oxc_linter/src/fixer/fix.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,6 @@ impl<'a> CompositeFix<'a> {
587587
};
588588

589589
output.push_str(after);
590-
output.shrink_to_fit();
591590

592591
let mut fix = Fix::new(output, Span::new(start, end));
593592
if let Some(message) = merged_fix_message {

0 commit comments

Comments
 (0)