From 168a91a9ddc331cd3b8e5c32f7701f2b0973b147 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 10 Nov 2019 06:17:09 -0500 Subject: optimize attribute setting a bit --- src/cell.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/cell.rs') 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 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] } } -- cgit v1.2.3-54-g00ecf