authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-10-04 17:06:17 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-10-04 17:06:17 -07:00
log3e78c04989f399bea229645ee7734b2a5d8be102
tree2f7e7e1999ca837963898e26a809f7f65b99de69
parent47125b3d059731a9341ba078e2ae7bf524ffa444

improve perf of generate script runner

cursor now stays on the same line and only goes left to right

1 files changed, 8 insertions(+), 4 deletions(-)

scripts/_common.zig+8-4
......@@ -49,12 +49,15 @@ pub fn Main(comptime T: type) type {
4949 const r = req.reader();
5050
5151 var line_num: usize = 1;
52 std.debug.print("\n", .{});
52 // std.debug.print("\n", .{});
5353
5454 var arena = std.heap.ArenaAllocator.init(alloc);
5555 defer arena.deinit();
5656 while (true) {
57 const line = r.readUntilDelimiterAlloc(alloc, '\n', max_size) catch |e| if (e == error.EndOfStream) break else return e;
57 const line = r.readUntilDelimiterAlloc(alloc, '\n', max_size) catch |err| switch (err) {
58 error.EndOfStream => break,
59 else => |e| return e,
60 };
5861 defer alloc.free(line);
5962
6063 if (line.len == 0) {
......@@ -66,11 +69,12 @@ pub fn Main(comptime T: type) type {
6669
6770 try T.exec(arena.allocator(), line, w);
6871
69 std.debug.print("{s}", .{ansi.csi.CursorUp(1)});
72 std.debug.print("{s}", .{ansi.csi.CursorHorzAbs(1)});
7073 std.debug.print("{s}", .{ansi.csi.EraseInLine(0)});
71 std.debug.print("{d}\n", .{line_num});
74 std.debug.print("{d}", .{line_num});
7275 line_num += 1;
7376 }
77 std.debug.print("\n", .{});
7478 try w.writeAll(T.dest_footer);
7579 try bufw.flush();
7680 }