diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-11-10 06:17:09 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-11-10 08:08:14 -0500 |
commit | 168a91a9ddc331cd3b8e5c32f7701f2b0973b147 (patch) | |
tree | 6b2df47bf18a731a9814bb875ce231e28cad1bf0 /src/row.rs | |
parent | b04c0e6e97765aeb888479c5e0bc27d54de60659 (diff) | |
download | vt100-rust-168a91a9ddc331cd3b8e5c32f7701f2b0973b147.tar.gz vt100-rust-168a91a9ddc331cd3b8e5c32f7701f2b0973b147.zip |
optimize attribute setting a bit
Diffstat (limited to 'src/row.rs')
-rw-r--r-- | src/row.rs | 28 |
1 files changed, 20 insertions, 8 deletions
@@ -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, "{}", |