mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
perf(diagnostics): optimize string-buffer reallocations (#3897)
This improves `GraphicalReportHandler` logic by using a string-buffer with a capacity hint. That avoids growing the buffer from zero each time, saving a bunch of reallocations.
This commit is contained in:
parent
1f85f1a5f7
commit
92c21b266e
1 changed files with 2 additions and 2 deletions
|
|
@ -1122,9 +1122,9 @@ impl GraphicalReportHandler {
|
|||
let mut column = context_data.column();
|
||||
let mut offset = context_data.span().offset();
|
||||
let mut line_offset = offset;
|
||||
let mut line_str = String::with_capacity(context.len());
|
||||
let mut lines = Vec::with_capacity(1);
|
||||
let mut iter = context.chars().peekable();
|
||||
let mut line_str = String::new();
|
||||
let mut lines = Vec::new();
|
||||
while let Some(char) = iter.next() {
|
||||
offset += char.len_utf8();
|
||||
let mut at_end_of_file = false;
|
||||
|
|
|
|||
Loading…
Reference in a new issue