aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2020-07-31 17:04:06 +0200
committerAram Drevekenin <aram@poor.dev>2020-07-31 17:04:06 +0200
commitea53765d16689786349cb8fd115ed913962e354a (patch)
treeb08b7c58149d7cbf31525ff56940217043a4d161 /src
parentperformance improvements strike back (diff)
downloadsl0ppij-ea53765d16689786349cb8fd115ed913962e354a.tar.gz
sl0ppij-ea53765d16689786349cb8fd115ed913962e354a.tar.xz
sl0ppij-ea53765d16689786349cb8fd115ed913962e354a.zip
better reflow performance
Diffstat (limited to 'src')
-rw-r--r--src/main.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 56903c3a..c8457cb1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -229,11 +229,15 @@ impl TerminalOutput {
}
fn reflow_lines (&mut self) {
self.linebreak_indices.clear();
- let newline_indices: HashSet<&usize> = HashSet::from_iter(self.newline_indices.iter());
+
+ let mut newline_indices = self.newline_indices.iter();
+ let mut next_newline_index = newline_indices.next();
+
let mut x: u64 = 0;
for (i, _c) in self.characters.iter().enumerate() {
- if newline_indices.contains(&i) {
+ if next_newline_index == Some(&i) {
x = 0;
+ next_newline_index = newline_indices.next();
} else if x == self.display_cols as u64 && i < self.cursor_position {
self.linebreak_indices.push(i);
x = 0;
@@ -441,7 +445,6 @@ impl vte::Perform for TerminalOutput {
self.move_to_beginning_of_line();
} else if byte == 08 { // backspace
self.cursor_position -= 1;
- self.characters.remove(self.cursor_position);
} else if byte == 10 { // 0a, newline
self.add_newline();
}