diff --git a/src/handlers/graphical.rs b/src/handlers/graphical.rs index 9c1d7ab..f9ab4cc 100644 --- a/src/handlers/graphical.rs +++ b/src/handlers/graphical.rs @@ -1196,9 +1196,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; diff --git a/src/handlers/narratable.rs b/src/handlers/narratable.rs index c809124..f8d36ae 100644 --- a/src/handlers/narratable.rs +++ b/src/handlers/narratable.rs @@ -295,9 +295,9 @@ impl NarratableReportHandler { 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;