mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-25 13:16:11 +03:00
small optimizations
This commit is contained in:
@ -1291,11 +1291,13 @@ fn ttyRead(t: *libuv.Tty, n: isize, buf: []const u8) void {
|
|||||||
|
|
||||||
// C0 execute, let our stream handle this one but otherwise
|
// C0 execute, let our stream handle this one but otherwise
|
||||||
// continue since we're guaranteed to be back in ground.
|
// continue since we're guaranteed to be back in ground.
|
||||||
.execute => win.terminal_stream.next(c) catch |err|
|
.execute => win.terminal_stream.execute(c) catch |err|
|
||||||
log.err("error processing terminal data: {}", .{err}),
|
log.err("error processing terminal data: {}", .{err}),
|
||||||
|
|
||||||
// Otherwise, break out and go the slow path until we're
|
// Otherwise, break out and go the slow path until we're
|
||||||
// back in ground.
|
// back in ground. There is a slight optimization here where
|
||||||
|
// could try to find the next transition to ground but when
|
||||||
|
// I implemented that it didn't materially change performance.
|
||||||
else => break,
|
else => break,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1304,7 +1306,6 @@ fn ttyRead(t: *libuv.Tty, n: isize, buf: []const u8) void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (i < end) {
|
if (i < end) {
|
||||||
//log.warn("SLOW={}", .{end - i});
|
|
||||||
win.terminal_stream.nextSlice(buf[i..end]) catch |err|
|
win.terminal_stream.nextSlice(buf[i..end]) catch |err|
|
||||||
log.err("error processing terminal data: {}", .{err});
|
log.err("error processing terminal data: {}", .{err});
|
||||||
}
|
}
|
||||||
@ -1418,7 +1419,9 @@ pub fn horizontalTab(self: *Window) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn linefeed(self: *Window) !void {
|
pub fn linefeed(self: *Window) !void {
|
||||||
try self.terminal.linefeed();
|
// Small optimization: call index instead of linefeed because they're
|
||||||
|
// identical and this avoids one layer of function call overhead.
|
||||||
|
try self.terminal.index();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn carriageReturn(self: *Window) !void {
|
pub fn carriageReturn(self: *Window) !void {
|
||||||
|
@ -319,20 +319,21 @@ pub const RowIndexTag = enum {
|
|||||||
/// The max length for a given tag. This is a length, not an index,
|
/// The max length for a given tag. This is a length, not an index,
|
||||||
/// so it is 1-indexed. If the value is zero, it means that this
|
/// so it is 1-indexed. If the value is zero, it means that this
|
||||||
/// section of the screen is empty or disabled.
|
/// section of the screen is empty or disabled.
|
||||||
pub fn maxLen(self: RowIndexTag, screen: *const Screen) usize {
|
pub inline fn maxLen(self: RowIndexTag, screen: *const Screen) usize {
|
||||||
const rows_written = screen.rowsWritten();
|
|
||||||
|
|
||||||
return switch (self) {
|
return switch (self) {
|
||||||
// Screen can be any of the written rows
|
// Screen can be any of the written rows
|
||||||
.screen => rows_written,
|
.screen => screen.rowsWritten(),
|
||||||
|
|
||||||
// Viewport can be any of the written rows or the max size
|
// Viewport can be any of the written rows or the max size
|
||||||
// of a viewport.
|
// of a viewport.
|
||||||
.viewport => @minimum(screen.rows, rows_written),
|
.viewport => @minimum(screen.rows, screen.rowsWritten()),
|
||||||
|
|
||||||
// History is all the way up to the top of our active area. If
|
// History is all the way up to the top of our active area. If
|
||||||
// we haven't filled our active area, there is no history.
|
// we haven't filled our active area, there is no history.
|
||||||
.history => if (rows_written > screen.rows) rows_written - screen.rows else 0,
|
.history => history: {
|
||||||
|
const rows_written = screen.rowsWritten();
|
||||||
|
break :history if (rows_written > screen.rows) rows_written - screen.rows else 0;
|
||||||
|
},
|
||||||
|
|
||||||
// Active area can be any number of rows. We ignore rows
|
// Active area can be any number of rows. We ignore rows
|
||||||
// written here because this is the only row index that can
|
// written here because this is the only row index that can
|
||||||
|
@ -68,7 +68,7 @@ pub fn Stream(comptime Handler: type) type {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execute(self: *Self, c: u8) !void {
|
pub fn execute(self: *Self, c: u8) !void {
|
||||||
// log.warn("C0: {}", .{c});
|
// log.warn("C0: {}", .{c});
|
||||||
switch (@intToEnum(ansi.C0, c)) {
|
switch (@intToEnum(ansi.C0, c)) {
|
||||||
.NUL => {},
|
.NUL => {},
|
||||||
|
Reference in New Issue
Block a user