authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2025-10-10 03:53:12-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2025-10-10 12:13:35-07:00
logd629a146f5d3a487fa666c0a51f9e0683dde76b8
tree58bc780c2490f80521400bda706cfdb6f3de3bd1
parent9aeabad519159a89220e475a6a544cd7d3a5db37

Dir.realpathW: remove redundant buffer/copy

This same change was applied in 69007f096177143086e28da0dc1a0eff4efcc52c but accidentally reverted in 7bf740ee718f4b6109cd9fe7014d1784d48ada48

1 files changed, 5 insertions(+), 8 deletions(-)

lib/std/fs/Dir.zig+5-8
......@@ -1433,16 +1433,13 @@ pub fn realpathZ(self: Dir, pathname: [*:0]const u8, out_buffer: []u8) RealPathE
14331433/// See also `Dir.realpath`, `realpathW`.
14341434pub fn realpathW(self: Dir, pathname: []const u16, out_buffer: []u8) RealPathError![]u8 {
14351435 var wide_buf: [std.os.windows.PATH_MAX_WIDE]u16 = undefined;
1436
14371436 const wide_slice = try self.realpathW2(pathname, &wide_buf);
14381437
1439 var big_out_buf: [fs.max_path_bytes]u8 = undefined;
1440 const end_index = std.unicode.wtf16LeToWtf8(&big_out_buf, wide_slice);
1441 if (end_index > out_buffer.len)
1442 return error.NameTooLong;
1443 const result = out_buffer[0..end_index];
1444 @memcpy(result, big_out_buf[0..end_index]);
1445 return result;
1438 const len = std.unicode.calcWtf8Len(wide_slice);
1439 if (len > out_buffer.len) return error.NameTooLong;
1440
1441 const end_index = std.unicode.wtf16LeToWtf8(&out_buffer, wide_slice);
1442 return out_buffer[0..end_index];
14461443}
14471444
14481445/// Windows-only. Same as `Dir.realpath` except