From a192249c77f09b601e71fe1c746bf9ea70f7c534 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 31 Aug 2022 19:33:28 -0700 Subject: [PATCH] circbuf rotateToZero does nothing if its already at zero --- src/terminal/circ_buf.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/terminal/circ_buf.zig b/src/terminal/circ_buf.zig index af26c1a4b..12259ee7e 100644 --- a/src/terminal/circ_buf.zig +++ b/src/terminal/circ_buf.zig @@ -70,6 +70,9 @@ pub fn CircBuf(comptime T: type, comptime default: T) type { // TODO: this does this in the worst possible way by allocating. // rewrite to not allocate, its possible, I'm just lazy right now. + // If we're already at zero then do nothing. + if (self.tail == 0) return; + var buf = try alloc.alloc(T, self.storage.len); defer { self.head = if (self.full) 0 else self.len();