Skip to content

Commit f552d58

Browse files
committed
std: use Buffer.outStream in std/child_process.zig
1 parent 55e1f32 commit f552d58

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

lib/std/child_process.zig

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -758,37 +758,36 @@ fn windowsCreateProcess(app_name: [*:0]u16, cmd_line: [*:0]u16, envp_ptr: ?[*]u1
758758

759759
/// Caller must dealloc.
760760
/// Guarantees a null byte at result[result.len].
761-
fn windowsCreateCommandLine(allocator: *mem.Allocator, argv: []const []const u8) ![]u8 {
761+
fn windowsCreateCommandLine(allocator: *mem.Allocator, argv: []const []const u8) ![:0]u8 {
762762
var buf = try Buffer.initSize(allocator, 0);
763763
defer buf.deinit();
764-
765-
var buf_stream = buf.outStream();
764+
const buf_stream = buf.outStream();
766765

767766
for (argv) |arg, arg_i| {
768-
if (arg_i != 0) try buf.appendByte(' ');
767+
if (arg_i != 0) try buf_stream.writeByte(' ');
769768
if (mem.indexOfAny(u8, arg, " \t\n\"") == null) {
770-
try buf.append(arg);
769+
try buf_stream.writeAll(arg);
771770
continue;
772771
}
773-
try buf.appendByte('"');
772+
try buf_stream.writeByte('"');
774773
var backslash_count: usize = 0;
775774
for (arg) |byte| {
776775
switch (byte) {
777776
'\\' => backslash_count += 1,
778777
'"' => {
779778
try buf_stream.writeByteNTimes('\\', backslash_count * 2 + 1);
780-
try buf.appendByte('"');
779+
try buf_stream.writeByte('"');
781780
backslash_count = 0;
782781
},
783782
else => {
784783
try buf_stream.writeByteNTimes('\\', backslash_count);
785-
try buf.appendByte(byte);
784+
try buf_stream.writeByte(byte);
786785
backslash_count = 0;
787786
},
788787
}
789788
}
790789
try buf_stream.writeByteNTimes('\\', backslash_count * 2);
791-
try buf.appendByte('"');
790+
try buf_stream.writeByte('"');
792791
}
793792

794793
return buf.toOwnedSlice();

0 commit comments

Comments
 (0)