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:
Josh McKinney 2024-08-23 12:54:09 -07:00
parent 99ef8651aa
commit 2b391ac15d
No known key found for this signature in database
GPG key ID: 722287396A903BC5

View file

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