From 047e29fe72c976ad4a75e3323f8e4d3461b6a980 Mon Sep 17 00:00:00 2001 From: IntegratedQuantum Date: Fri, 1 Aug 2025 17:03:08 +0200 Subject: [PATCH] Avoid realPathAlloc in caching of _defaults fixes #1351 --- src/assets.zig | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/assets.zig b/src/assets.zig index 7cb3c605..8136f79b 100644 --- a/src/assets.zig +++ b/src/assets.zig @@ -155,14 +155,11 @@ pub const Assets = struct { self.localArena.deinit(); } - fn get(self: *Defaults, dir: std.fs.Dir) ZonElement { - const path = dir.realpathAlloc(main.stackAllocator.allocator, ".") catch unreachable; - defer main.stackAllocator.free(path); - - const result = self.defaults.getOrPut(self.localAllocator.allocator, path) catch unreachable; + fn get(self: *Defaults, dir: std.fs.Dir, dirPath: []const u8) ZonElement { + const result = self.defaults.getOrPut(self.localAllocator.allocator, dirPath) catch unreachable; if(!result.found_existing) { - result.key_ptr.* = self.localAllocator.dupe(u8, path); + result.key_ptr.* = self.localAllocator.dupe(u8, dirPath); const default: ZonElement = self.read(dir) catch |err| blk: { std.log.err("Failed to read default file: {s}", .{@errorName(err)}); break :blk .null; @@ -224,7 +221,7 @@ pub const Assets = struct { continue; }; if(hasDefaults) { - zon.join(defaultsStorage.get(entry.dir)); + zon.join(defaultsStorage.get(entry.dir, entry.path[0 .. entry.path.len - entry.basename.len])); } output.put(allocator.allocator, id, zon) catch unreachable; }