config: packed struct fields can clone directly via copy

This commit is contained in:
Mitchell Hashimoto
2023-11-07 17:09:03 -08:00
parent bb39bab5dc
commit d0666e523f

View File

@ -4,6 +4,7 @@ const Config = @This();
const std = @import("std"); const std = @import("std");
const builtin = @import("builtin"); const builtin = @import("builtin");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator; const Allocator = std.mem.Allocator;
const ArenaAllocator = std.heap.ArenaAllocator; const ArenaAllocator = std.heap.ArenaAllocator;
const fontpkg = @import("../font/main.zig"); const fontpkg = @import("../font/main.zig");
@ -1370,7 +1371,11 @@ fn cloneValue(alloc: Allocator, comptime T: type, src: T) !T {
src orelse return null, src orelse return null,
), ),
.Struct => return try src.clone(alloc), .Struct => |info| {
// Packed structs we can return directly as copies.
assert(info.layout == .Packed);
return src;
},
else => { else => {
@compileLog(T); @compileLog(T);