mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
fastmem: rotateOnce
This commit is contained in:
@ -22,5 +22,13 @@ pub inline fn copy(comptime T: type, dest: []T, source: []const T) void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Same as std.mem.rotate(T, items, 1) but more efficient by using memmove
|
||||||
|
/// and a tmp var for the single rotated item instead of 3 calls to reverse.
|
||||||
|
pub inline fn rotateOnce(comptime T: type, items: []T) void {
|
||||||
|
const tmp = items[0];
|
||||||
|
move(T, items[0..items.len - 1], items[1..items.len]);
|
||||||
|
items[items.len - 1] = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
extern "c" fn memcpy(*anyopaque, *const anyopaque, usize) *anyopaque;
|
extern "c" fn memcpy(*anyopaque, *const anyopaque, usize) *anyopaque;
|
||||||
extern "c" fn memmove(*anyopaque, *const anyopaque, usize) *anyopaque;
|
extern "c" fn memmove(*anyopaque, *const anyopaque, usize) *anyopaque;
|
||||||
|
@ -6,6 +6,7 @@ const PageList = @This();
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const assert = std.debug.assert;
|
const assert = std.debug.assert;
|
||||||
|
const fastmem = @import("../fastmem.zig");
|
||||||
const point = @import("point.zig");
|
const point = @import("point.zig");
|
||||||
const pagepkg = @import("page.zig");
|
const pagepkg = @import("page.zig");
|
||||||
const stylepkg = @import("style.zig");
|
const stylepkg = @import("style.zig");
|
||||||
@ -2001,7 +2002,7 @@ pub fn eraseRow(
|
|||||||
// In order to move the following rows up we rotate the rows array by 1.
|
// In order to move the following rows up we rotate the rows array by 1.
|
||||||
// The rotate operation turns e.g. [ 0 1 2 3 ] in to [ 1 2 3 0 ], which
|
// The rotate operation turns e.g. [ 0 1 2 3 ] in to [ 1 2 3 0 ], which
|
||||||
// works perfectly to move all of our elements where they belong.
|
// works perfectly to move all of our elements where they belong.
|
||||||
std.mem.rotate(Row, rows[pn.y..page.data.size.rows], 1);
|
fastmem.rotateOnce(Row, rows[pn.y..page.data.size.rows]);
|
||||||
|
|
||||||
// We adjust the tracked pins in this page, moving up any that were below
|
// We adjust the tracked pins in this page, moving up any that were below
|
||||||
// the removed row.
|
// the removed row.
|
||||||
@ -2038,7 +2039,7 @@ pub fn eraseRow(
|
|||||||
page = next;
|
page = next;
|
||||||
rows = next_rows;
|
rows = next_rows;
|
||||||
|
|
||||||
std.mem.rotate(Row, rows[0..page.data.size.rows], 1);
|
fastmem.rotateOnce(Row, rows[0..page.data.size.rows]);
|
||||||
|
|
||||||
// Our tracked pins for this page need to be updated.
|
// Our tracked pins for this page need to be updated.
|
||||||
// If the pin is in row 0 that means the corresponding row has
|
// If the pin is in row 0 that means the corresponding row has
|
||||||
|
Reference in New Issue
Block a user