From 819bc247a09191ef32c8e51fb99d2bca351f172b Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 22 Feb 2019 21:52:18 -0800 Subject: [PATCH] micro optimize clearing a line Turns out to be faster to clear and then resize than it is to resize down and manually assign the elements --- termwiz/src/surface/line.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/termwiz/src/surface/line.rs b/termwiz/src/surface/line.rs index d51e91821..20679fcdd 100644 --- a/termwiz/src/surface/line.rs +++ b/termwiz/src/surface/line.rs @@ -56,10 +56,8 @@ impl Line { pub fn resize_and_clear(&mut self, width: usize) { let blank = Cell::default(); + self.cells.clear(); self.cells.resize(width, blank); - for cell in &mut self.cells { - *cell = Cell::default(); - } self.bits = LineBits::DIRTY; }