check for needless allocation in CellBuffer::resize()

embed
Manos Pitsidianakis 5 years ago
parent abf8878b39
commit 99d0f81b60
No known key found for this signature in database
GPG Key ID: 73627C2F690DF710

@ -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 {

Loading…
Cancel
Save