aboutsummaryrefslogtreecommitdiffstats
path: root/src/cell.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/cell.rs
parentb04c0e6e97765aeb888479c5e0bc27d54de60659 (diff)
downloadvt100-rust-168a91a9ddc331cd3b8e5c32f7701f2b0973b147.tar.gz
vt100-rust-168a91a9ddc331cd3b8e5c32f7701f2b0973b147.zip
optimize attribute setting a bit
Diffstat (limited to 'src/cell.rs')
-rw-r--r--src/cell.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/cell.rs b/src/cell.rs
index 61a3cd3..b9d7168 100644
--- a/src/cell.rs
+++ b/src/cell.rs
@@ -11,15 +11,22 @@ pub struct Cell {
attrs: crate::attrs::Attrs,
}
+#[allow(clippy::collapsible_if)]
impl PartialEq<Cell> for Cell {
fn eq(&self, other: &Self) -> bool {
- if self.attrs != other.attrs {
- return false;
- }
if self.len != other.len {
return false;
}
let len = self.len as usize;
+ if len > 0 {
+ if self.attrs != other.attrs {
+ return false;
+ }
+ } else {
+ if self.attrs.bgcolor != other.attrs.bgcolor {
+ return false;
+ }
+ }
self.contents[..len] == other.contents[..len]
}
}