on master help sign in
Don't calculate symbol width twice

This is potentially costly so we should avoid calling width()

commitac81b47a41a26ff18419466b129b34921864add2 authorBlaž Hrastnik <blaz@mxxn.io> dateWed 19 Jan 2022, 17:01 (5 years ago) parent66a8612
1 file changed+3−2
helix-tui/src/buffer.rs+3−2
helix-tui/src/buffer.rs+3−2
@@ -535,9 +535,10 @@ impl Buffer {
535535 updates.push((x, y, &next_buffer[i]));
536536 }
537537
538− to_skip = current.symbol.width().saturating_sub(1);
538+ let current_width = current.symbol.width();
539+ to_skip = current_width.saturating_sub(1);
539540
540− let affected_width = std::cmp::max(current.symbol.width(), previous.symbol.width());
541+ let affected_width = std::cmp::max(current_width, previous.symbol.width());
541542 invalidated = std::cmp::max(affected_width, invalidated).saturating_sub(1);
542543 }
543544 updates