mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-09 11:26:41 +00:00
fix:use builtin memmove (#9033)
This commit is contained in:
@@ -2,20 +2,13 @@ const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const assert = std.debug.assert;
|
||||
|
||||
/// Same as std.mem.copyForwards/Backwards but prefers libc memmove if it is
|
||||
/// available because it is generally much faster.
|
||||
/// Same as @memmove but prefers libc memmove if it is
|
||||
/// available because it is generally much faster?.
|
||||
pub inline fn move(comptime T: type, dest: []T, source: []const T) void {
|
||||
if (builtin.link_libc) {
|
||||
_ = memmove(dest.ptr, source.ptr, source.len * @sizeOf(T));
|
||||
} else {
|
||||
// Depending on the ordering of the copy, we need to use the
|
||||
// proper call here. Unfortunately this function call is
|
||||
// too generic to know this at comptime.
|
||||
if (@intFromPtr(dest.ptr) <= @intFromPtr(source.ptr)) {
|
||||
std.mem.copyForwards(T, dest, source);
|
||||
} else {
|
||||
std.mem.copyBackwards(T, dest, source);
|
||||
}
|
||||
@memmove(dest, source);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user