Skip to content

Commit

Permalink
Don't calculate symbol width twice
Browse files Browse the repository at this point in the history
This is potentially costly so we should avoid calling width()
  • Loading branch information
archseer committed Jan 23, 2022
1 parent 66a8612 commit ac81b47
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions helix-tui/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,10 @@ impl Buffer {
updates.push((x, y, &next_buffer[i]));
}

to_skip = current.symbol.width().saturating_sub(1);
let current_width = current.symbol.width();
to_skip = current_width.saturating_sub(1);

let affected_width = std::cmp::max(current.symbol.width(), previous.symbol.width());
let affected_width = std::cmp::max(current_width, previous.symbol.width());
invalidated = std::cmp::max(affected_width, invalidated).saturating_sub(1);
}
updates
Expand Down

0 comments on commit ac81b47

Please sign in to comment.