check for needless allocation in CellBuffer::resize()

embed
Manos Pitsidianakis 2019-02-21 15:30:13 +02:00
parent abf8878b39
commit 99d0f81b60
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
1 changed files with 3 additions and 0 deletions

View File

@ -141,6 +141,9 @@ impl CellBuffer {
/// a blank.
pub fn resize(&mut self, newcols: usize, newrows: usize, blank: Cell) {
let newlen = newcols * newrows;
if self.buf.len() == newlen {
return;
}
let mut newbuf: Vec<Cell> = Vec::with_capacity(newlen);
for y in 0..newrows {
for x in 0..newcols {