From ac358d913c452ad66bb4fe4f76627e119604ea3e Mon Sep 17 00:00:00 2001 From: Aram Drevekenin Date: Fri, 12 Mar 2021 14:27:13 +0100 Subject: [PATCH] fix(performance): smaller allocations when rendering (#222) --- src/client/panes/terminal_pane.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/client/panes/terminal_pane.rs b/src/client/panes/terminal_pane.rs index fd83d571..4a0321af 100644 --- a/src/client/panes/terminal_pane.rs +++ b/src/client/panes/terminal_pane.rs @@ -205,12 +205,11 @@ impl Pane for TerminalPane { for line_index in 0..self.grid.height { let x = self.get_x(); let y = self.get_y(); - vte_output = format!( - "{}\u{1b}[{};{}H\u{1b}[m", - vte_output, + vte_output.push_str(&format!( + "\u{1b}[{};{}H\u{1b}[m", y + line_index + 1, x + 1 - ); // goto row/col and reset styles + )); // goto row/col and reset styles for _col_index in 0..self.grid.width { vte_output.push(EMPTY_TERMINAL_CHARACTER.character); } @@ -220,7 +219,7 @@ impl Pane for TerminalPane { for (row, line) in buffer_lines.iter().enumerate() { let x = self.get_x(); let y = self.get_y(); - vte_output = format!("{}\u{1b}[{};{}H\u{1b}[m", vte_output, y + row + 1, x + 1); // goto row/col and reset styles + vte_output.push_str(&format!("\u{1b}[{};{}H\u{1b}[m", y + row + 1, x + 1)); // goto row/col and reset styles for (col, t_character) in line.iter().enumerate() { if col < display_cols { // in some cases (eg. while resizing) some characters will spill over @@ -232,7 +231,7 @@ impl Pane for TerminalPane { // the terminal keeps the previous styles as long as we're in the same // line, so we only want to update the new styles here (this also // includes resetting previous styles as needed) - vte_output = format!("{}{}", vte_output, new_styles); + vte_output.push_str(&new_styles.to_string()); } vte_output.push(t_character.character); }