From ce85d9a2cdc8c880f38e8483b573314bc46db12c Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 8 Nov 2022 19:15:14 -0800 Subject: [PATCH] add more tracing, unroll a loop --- src/terminal/Screen.zig | 3 +++ src/terminal/circ_buf.zig | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index cedf832ca..66fd60ef8 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -1023,6 +1023,9 @@ pub fn scroll(self: *Screen, behavior: Scroll) !void { } fn scrollDelta(self: *Screen, delta: isize, grow: bool) !void { + const tracy = trace(@src()); + defer tracy.end(); + // If we're scrolling up, then we just subtract and we're done. // We just clamp at 0 which blocks us from scrolling off the top. if (delta < 0) { diff --git a/src/terminal/circ_buf.zig b/src/terminal/circ_buf.zig index 9fc61141c..926addb63 100644 --- a/src/terminal/circ_buf.zig +++ b/src/terminal/circ_buf.zig @@ -46,6 +46,9 @@ pub fn CircBuf(comptime T: type, comptime default: T) type { /// Resize the buffer to the given size (larger or smaller). /// If larger, new values will be set to the default value. pub fn resize(self: *Self, alloc: Allocator, size: usize) !void { + const tracy = trace(@src()); + defer tracy.end(); + // Rotate to zero so it is aligned. try self.rotateToZero(alloc); @@ -69,6 +72,9 @@ pub fn CircBuf(comptime T: type, comptime default: T) type { /// Rotate the data so that it is zero-aligned. fn rotateToZero(self: *Self, alloc: Allocator) !void { + const tracy = trace(@src()); + defer tracy.end(); + // TODO: this does this in the worst possible way by allocating. // rewrite to not allocate, its possible, I'm just lazy right now. @@ -116,9 +122,12 @@ pub fn CircBuf(comptime T: type, comptime default: T) type { pub fn deleteOldest(self: *Self, n: usize) void { assert(n <= self.storage.len); + const tracy = trace(@src()); + defer tracy.end(); + // Clear the values back to default const slices = self.getPtrSlice(0, n); - for (slices) |slice| std.mem.set(T, slice, default); + inline for (slices) |slice| std.mem.set(T, slice, default); // If we're not full, we can just advance the tail. We know // it'll be less than the length because otherwise we'd be full.