mirror of
https://github.com/ratatui-org/ratatui
synced 2024-11-22 04:33:13 +00:00
perf: only calculate current symbol width once
This is a 20% performance improvement on buffer diff on my M2 MBP. ``` buffer/diff time: [100.26 µs 100.69 µs 101.15 µs] change: [-18.007% -17.489% -16.929%] (p = 0.00 < 0.05) Performance has improved. ```
This commit is contained in:
parent
99ef8651aa
commit
2b391ac15d
1 changed files with 4 additions and 3 deletions
|
@ -499,9 +499,10 @@ impl Buffer {
|
|||
updates.push((x, y, &next_buffer[i]));
|
||||
}
|
||||
|
||||
to_skip = current.symbol().width().saturating_sub(1);
|
||||
|
||||
let affected_width = std::cmp::max(current.symbol().width(), previous.symbol().width());
|
||||
let current_symbol_width = current.symbol().width();
|
||||
let previous_symbol_width = previous.symbol().width();
|
||||
to_skip = current_symbol_width.saturating_sub(1);
|
||||
let affected_width = std::cmp::max(current_symbol_width, previous_symbol_width);
|
||||
invalidated = std::cmp::max(affected_width, invalidated).saturating_sub(1);
|
||||
}
|
||||
updates
|
||||
|
|
Loading…
Reference in a new issue