authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-04-07 17:22:02-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-04-08 14:30:28+02:00
logcf0f6dd17fc9c534b11c6a3f3f6e448702a9a93a
tree25b694907b00f33b9da6418e05fb1acf211ec6a0
parent9fd63daff2f6b98c2c7ae3a2668d2fa6cd92589c

Io.Threaded: Reduce dirRealPathFileWindows stack usage by 64KiB

This effectively reinstates the changes made in https://github.com/ziglang/zig/pull/23657 that were lost in the transition to std.Io

1 files changed, 9 insertions(+), 2 deletions(-)

lib/std/Io/Threaded.zig+9-2
......@@ -6090,12 +6090,19 @@ fn dirRealPathFileWindows(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8,
60906090 }
60916091 };
60926092 defer windows.CloseHandle(h_file);
6093 return realPathWindows(h_file, out_buffer);
6093
6094 // We can re-use the path buffer for the WTF-16 representation since
6095 // we don't need the prefixed path anymore
6096 return realPathWindowsBuf(h_file, out_buffer, &path_name_w.data);
60946097}
60956098
60966099fn realPathWindows(h_file: windows.HANDLE, out_buffer: []u8) File.RealPathError!usize {
60976100 var wide_buf: [windows.PATH_MAX_WIDE]u16 = undefined;
6098 const wide_slice = try GetFinalPathNameByHandle(h_file, .{}, &wide_buf);
6101 return realPathWindowsBuf(h_file, out_buffer, &wide_buf);
6102}
6103
6104fn realPathWindowsBuf(h_file: windows.HANDLE, out_buffer: []u8, wtf16_buffer: []u16) File.RealPathError!usize {
6105 const wide_slice = try GetFinalPathNameByHandle(h_file, .{}, wtf16_buffer);
60996106
61006107 const len = std.unicode.calcWtf8Len(wide_slice);
61016108 if (len > out_buffer.len)