diff --git a/lib/std/Build/Cache/Path.zig b/lib/std/Build/Cache/Path.zig index f946227eb632d59cd0025efab4a98507c62de487..9d9501013cc20f09b53dc3ad54e5b9124883776d 100644 --- a/lib/std/Build/Cache/Path.zig +++ b/lib/std/Build/Cache/Path.zig @@ -178,22 +178,15 @@ pub fn formatEscapeChar(path: Path, writer: *Io.Writer) Io.Writer.Error!void { pub fn format(self: Path, writer: *Io.Writer) Io.Writer.Error!void { if (Io.Dir.path.isAbsolute(self.sub_path)) { - try writer.writeAll(self.sub_path); - return; + return writer.writeAll(self.sub_path); + } else if (self.root_dir.path) |p| { + var bufs: [3][]const u8 = .{ p, Io.Dir.path.sep_str, self.sub_path }; + return writer.writeVecAll(bufs[0..if (self.sub_path.len > 0) 3 else 1]); + } else if (self.sub_path.len > 0) { + return writer.writeAll(self.sub_path); + } else { + return writer.writeByte('.'); } - if (self.root_dir.path) |p| { - try writer.writeAll(p); - if (self.sub_path.len > 0) { - try writer.writeAll(Io.Dir.path.sep_str); - try writer.writeAll(self.sub_path); - } - return; - } - if (self.sub_path.len > 0) { - try writer.writeAll(self.sub_path); - return; - } - try writer.writeByte('.'); } pub fn eql(self: Path, other: Path) bool {