Minor optimization of line number length logic (#26845)

In `layout_excerpt_gutter`, compute max line number length once instead
of for every row

In `max_line_number_width`, use ilog10 instead of converting to floats
and back

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-03-15 13:28:50 -06:00 committed by GitHub
parent c220fb387d
commit ef91e7afae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 11 deletions

View file

@ -4096,6 +4096,7 @@ impl MultiBufferSnapshot {
}
pub fn widest_line_number(&self) -> u32 {
// widest_line_number is 0-based, so 1 is added to get the displayed line number.
self.excerpts.summary().widest_line_number + 1
}