aboutsummaryrefslogtreecommitdiffstats
path: root/src/row.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-11-10 06:17:09 -0500
committerJesse Luehrs <doy@tozt.net>2019-11-10 08:08:14 -0500
commit168a91a9ddc331cd3b8e5c32f7701f2b0973b147 (patch)
tree6b2df47bf18a731a9814bb875ce231e28cad1bf0 /src/row.rs
parentb04c0e6e97765aeb888479c5e0bc27d54de60659 (diff)
downloadvt100-rust-168a91a9ddc331cd3b8e5c32f7701f2b0973b147.tar.gz
vt100-rust-168a91a9ddc331cd3b8e5c32f7701f2b0973b147.zip
optimize attribute setting a bit
Diffstat (limited to 'src/row.rs')
-rw-r--r--src/row.rs28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/row.rs b/src/row.rs
index f7d4485..1f10872 100644
--- a/src/row.rs
+++ b/src/row.rs
@@ -165,12 +165,13 @@ impl Row {
}
let attrs = cell.attrs();
- if &prev_attrs != attrs {
- attrs.write_escape_code_diff(contents, &prev_attrs);
- prev_attrs = *attrs;
- }
if has_contents {
+ if &prev_attrs != attrs {
+ attrs.write_escape_code_diff(contents, &prev_attrs);
+ prev_attrs = *attrs;
+ }
+
// using write! here is significantly slower, for some
// reason
// write!(contents, "{}", cell.contents()).unwrap();
@@ -179,6 +180,11 @@ impl Row {
prev_pos.col += width;
new_pos.col += width;
} else {
+ if prev_attrs.bgcolor != attrs.bgcolor {
+ attrs.write_escape_code_diff(contents, &prev_attrs);
+ prev_attrs = *attrs;
+ }
+
write!(
contents,
"{}",
@@ -262,12 +268,13 @@ impl Row {
}
let attrs = cell.attrs();
- if &prev_attrs != attrs {
- attrs.write_escape_code_diff(contents, &prev_attrs);
- prev_attrs = *attrs;
- }
if cell.has_contents() {
+ if &prev_attrs != attrs {
+ attrs.write_escape_code_diff(contents, &prev_attrs);
+ prev_attrs = *attrs;
+ }
+
// using write! here is significantly slower, for some
// reason
// write!(contents, "{}", cell.contents()).unwrap();
@@ -276,6 +283,11 @@ impl Row {
prev_pos.col += width;
new_pos.col += width;
} else {
+ if prev_attrs.bgcolor != attrs.bgcolor {
+ attrs.write_escape_code_diff(contents, &prev_attrs);
+ prev_attrs = *attrs;
+ }
+
write!(
contents,
"{}",