refactor: avoid unnecessary casts

This commit is contained in:
Miguel Granero 2026-02-11 12:48:33 +01:00 committed by CJ van den Berg
parent d60611deba
commit 1034872e8f

View file

@ -1557,19 +1557,18 @@ pub const Editor = struct {
.bg = if (hl_row) |_| theme.editor_line_highlight.bg else theme.editor_hint.bg,
});
var summary_freespace: i32 = @intCast(screen_width - space_begin);
const static_text = "  , ";
summary_freespace -= @intCast(static_text.len + commit.author.len);
const summary_freespace = screen_width -| (space_begin + static_text.len + commit.author.len);
var buf: std.Io.Writer.Allocating = .init(self.allocator);
defer buf.deinit();
if (summary_freespace >= @as(i32, @intCast(commit.summary.len))) {
if (summary_freespace >= commit.summary.len) {
_ = buf.writer.print("  {s}, {s}", .{ commit.summary, commit.author }) catch 0;
} else if (summary_freespace <= 3) {
_ = buf.writer.print("  {s}", .{commit.author}) catch 0;
} else {
_ = buf.writer.print("  {s}..., {s}", .{ commit.summary[0 .. @as(usize, @intCast(summary_freespace)) - 3], commit.author }) catch 0;
_ = buf.writer.print("  {s}..., {s}", .{ commit.summary[0..summary_freespace -| 3], commit.author }) catch 0;
}
const msg = buf.written();