add some TODOs

This commit is contained in:
Mitchell Hashimoto
2022-04-26 19:45:12 -07:00
parent 17c6d24bc2
commit 7025b53544
2 changed files with 10 additions and 5 deletions

5
TODO.md Normal file
View File

@ -0,0 +1,5 @@
Performance:
* libuv allocates on every read, we should use a read buffer pool
* update cells for drawing should just happen once per frame
* update cells should only update the changed cells

View File

@ -57,7 +57,7 @@ write_req_pool: SegmentedPool(libuv.WriteReq.T, WRITE_REQ_PREALLOC) = .{},
/// The pool of available buffers for writing to the pty.
/// TODO: [1]u8 is probably not right.
buf_pool: SegmentedPool([1]u8, WRITE_REQ_PREALLOC) = .{},
write_buf_pool: SegmentedPool([1]u8, WRITE_REQ_PREALLOC) = .{},
/// Set this to true whenver an event occurs that we may want to wake up
/// the event loop. Only set this from the main thread.
@ -220,7 +220,7 @@ pub fn destroy(self: *Window) void {
const alloc = win.alloc;
t.deinit(alloc);
win.write_req_pool.deinit(alloc);
win.buf_pool.deinit(alloc);
win.write_buf_pool.deinit(alloc);
win.alloc.destroy(win);
}
}).callback);
@ -283,7 +283,7 @@ fn charCallback(window: glfw.Window, codepoint: u21) void {
// Write the character to the pty
const req = win.write_req_pool.get() catch unreachable;
const buf = win.buf_pool.get() catch unreachable;
const buf = win.write_buf_pool.get() catch unreachable;
buf[0] = @intCast(u8, codepoint);
win.pty_stream.write(
.{ .req = req },
@ -312,7 +312,7 @@ fn keyCallback(
const win = window.getUserPointer(Window) orelse return;
const req = win.write_req_pool.get() catch unreachable;
const buf = win.buf_pool.get() catch unreachable;
const buf = win.write_buf_pool.get() catch unreachable;
buf[0] = c;
win.pty_stream.write(
.{ .req = req },
@ -373,7 +373,7 @@ fn ttyWrite(req: *libuv.WriteReq, status: i32) void {
const tty = req.handle(libuv.Tty).?;
const win = tty.getData(Window).?;
win.write_req_pool.put();
win.buf_pool.put();
win.write_buf_pool.put();
libuv.convertError(status) catch |err|
log.err("write error: {}", .{err});