add more tracing, unroll a loop

This commit is contained in:
Mitchell Hashimoto
2022-11-08 19:15:14 -08:00
parent d1718e6cbf
commit ce85d9a2cd
2 changed files with 13 additions and 1 deletions

View File

@ -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) {

View File

@ -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.