Use repeat byte when discovering squeeze

This commit is contained in:
Sharif Haason authored and David Peter committed 2022-11-13 22:15:41 +01:00
1 parent 1e43783616
commit 828fb210ce
1 file changed
+6 -2
+6 -2
View File
@@ -529,11 +529,15 @@ impl<'a, Writer: Write> Printer<'a, Writer> {
self.squeezer = Squeezer::Delete;
}
let repeat_byte = (self.line_buf[0] as usize) * (usize::MAX / 255);
if !matches!(self.squeezer, Squeezer::Disabled | Squeezer::Delete)
&& self.line_buf.windows(2).all(|w| w[0] == w[1])
&& self
.line_buf
.chunks_exact(std::mem::size_of::<usize>())
.all(|w| usize::from_ne_bytes(w.try_into().unwrap()) == repeat_byte)
{
self.squeezer = Squeezer::Print;
self.squeeze_byte = (self.line_buf[0] as usize) * (usize::MAX / 255);
self.squeeze_byte = repeat_byte;
};
};