aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-12-07 08:21:04 -0500
committerJesse Luehrs <doy@tozt.net>2019-12-07 08:21:04 -0500
commit2234ccb9cde70d9b9fcc26a85523ffc97e3bebc6 (patch)
tree60ed5a22857ec3b5f89444c285d13466030a6e58
parentaad033314bfced2ae471281641c052c06622a8ae (diff)
downloadvt100-rust-2234ccb9cde70d9b9fcc26a85523ffc97e3bebc6.tar.gz
vt100-rust-2234ccb9cde70d9b9fcc26a85523ffc97e3bebc6.zip
avoid calculating contents multiple times
-rw-r--r--src/row.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/row.rs b/src/row.rs
index 76dd1d5..16c59a4 100644
--- a/src/row.rs
+++ b/src/row.rs
@@ -207,17 +207,17 @@ impl Row {
}
prev_pos.col += if cell.is_wide() { 2 } else { 1 };
+ let cell_contents = cell.contents();
if prev_pos.col >= self.cols()
&& !self.wrapped
&& cell.is_wide()
- && cell.contents().chars().count() > 1
+ && cell_contents.chars().count() > 1
{
// alternately, we could backspace enough to overwrite
// the second to last character, then ICH and rewrite
// the second to last character and then reposition,
// but that's a lot more complicated and not sure if
// it's worth it for this much of an edge case
- let cell_contents = cell.contents();
let mut chars = cell_contents.chars();
let base = chars.next().unwrap();
let mut bytes = [0; 4];
@@ -228,7 +228,7 @@ impl Row {
.extend(c.encode_utf8(&mut bytes).bytes());
}
} else {
- contents.extend(cell.contents().as_bytes());
+ contents.extend(cell_contents.as_bytes());
}
} else if erase.is_none() {
erase = Some((pos.col, attrs));