diff options
author | Blaž Hrastnik | 2022-01-19 08:01:26 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2022-01-23 07:04:26 +0000 |
commit | ac81b47a41a26ff18419466b129b34921864add2 (patch) | |
tree | c5492bff91638384dcacc408e8891e40656164c5 | |
parent | 66a86123513ea5d6e9b7747eb3949a2695f23bee (diff) |
Don't calculate symbol width twice
This is potentially costly so we should avoid calling width()
-rw-r--r-- | helix-tui/src/buffer.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/helix-tui/src/buffer.rs b/helix-tui/src/buffer.rs index 3c5e09ac..f8673e43 100644 --- a/helix-tui/src/buffer.rs +++ b/helix-tui/src/buffer.rs @@ -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 |