mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
termio: inspector forces byte-at-a-time processing
This commit is contained in:
@ -1133,17 +1133,20 @@ const ReadThread = struct {
|
|||||||
// Schedule a render
|
// Schedule a render
|
||||||
ev.queueRender() catch unreachable;
|
ev.queueRender() catch unreachable;
|
||||||
|
|
||||||
// If we have an inspector, send the data to it too. The inspector
|
// If we have an inspector, we enter SLOW MODE because we need to
|
||||||
// will keep track of the VT sequences that we are processing.
|
// process a byte at a time alternating between the inspector handler
|
||||||
|
// and the termio handler. This is very slow compared to our optimizations
|
||||||
|
// below but at least users only pay for it if they're using the inspector.
|
||||||
if (ev.renderer_state.inspector) |insp| {
|
if (ev.renderer_state.inspector) |insp| {
|
||||||
// This forces all VT sequences to be parsed twice, meaning our
|
for (buf, 0..) |byte, i| {
|
||||||
// vt processing always slows down by roughly 50% with the inspector
|
insp.recordPtyRead(buf[i .. i + 1]) catch |err| {
|
||||||
// active. That's fine for now but room for improvement.
|
|
||||||
insp.recordPtyRead(buf) catch |err| {
|
|
||||||
log.err("error recording pty read in inspector err={}", .{err});
|
log.err("error recording pty read in inspector err={}", .{err});
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
|
ev.terminal_stream.next(byte) catch |err|
|
||||||
|
log.err("error processing terminal data: {}", .{err});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// Process the terminal data. This is an extremely hot part of the
|
// Process the terminal data. This is an extremely hot part of the
|
||||||
// terminal emulator, so we do some abstraction leakage to avoid
|
// terminal emulator, so we do some abstraction leakage to avoid
|
||||||
// function calls and unnecessary logic.
|
// function calls and unnecessary logic.
|
||||||
@ -1182,6 +1185,7 @@ const ReadThread = struct {
|
|||||||
ev.terminal_stream.nextSlice(buf[i..end]) catch |err|
|
ev.terminal_stream.nextSlice(buf[i..end]) catch |err|
|
||||||
log.err("error processing terminal data: {}", .{err});
|
log.err("error processing terminal data: {}", .{err});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If our stream handling caused messages to be sent to the writer
|
// If our stream handling caused messages to be sent to the writer
|
||||||
// thread, then we need to wake it up so that it processes them.
|
// thread, then we need to wake it up so that it processes them.
|
||||||
|
Reference in New Issue
Block a user