mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 09:16:11 +03:00
add more tracing, unroll a loop
This commit is contained in:
@ -1023,6 +1023,9 @@ pub fn scroll(self: *Screen, behavior: Scroll) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn scrollDelta(self: *Screen, delta: isize, grow: bool) !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.
|
// 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.
|
// We just clamp at 0 which blocks us from scrolling off the top.
|
||||||
if (delta < 0) {
|
if (delta < 0) {
|
||||||
|
@ -46,6 +46,9 @@ pub fn CircBuf(comptime T: type, comptime default: T) type {
|
|||||||
/// Resize the buffer to the given size (larger or smaller).
|
/// Resize the buffer to the given size (larger or smaller).
|
||||||
/// If larger, new values will be set to the default value.
|
/// If larger, new values will be set to the default value.
|
||||||
pub fn resize(self: *Self, alloc: Allocator, size: usize) !void {
|
pub fn resize(self: *Self, alloc: Allocator, size: usize) !void {
|
||||||
|
const tracy = trace(@src());
|
||||||
|
defer tracy.end();
|
||||||
|
|
||||||
// Rotate to zero so it is aligned.
|
// Rotate to zero so it is aligned.
|
||||||
try self.rotateToZero(alloc);
|
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.
|
/// Rotate the data so that it is zero-aligned.
|
||||||
fn rotateToZero(self: *Self, alloc: Allocator) !void {
|
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.
|
// TODO: this does this in the worst possible way by allocating.
|
||||||
// rewrite to not allocate, its possible, I'm just lazy right now.
|
// 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 {
|
pub fn deleteOldest(self: *Self, n: usize) void {
|
||||||
assert(n <= self.storage.len);
|
assert(n <= self.storage.len);
|
||||||
|
|
||||||
|
const tracy = trace(@src());
|
||||||
|
defer tracy.end();
|
||||||
|
|
||||||
// Clear the values back to default
|
// Clear the values back to default
|
||||||
const slices = self.getPtrSlice(0, n);
|
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
|
// 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.
|
// it'll be less than the length because otherwise we'd be full.
|
||||||
|
Reference in New Issue
Block a user