Skip to content

Commit 471b8ce

Browse files
committed
std: use Buffer.outStream in std/child_process.zig
1 parent a526ee8 commit 471b8ce

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
@@ -776,37 +776,36 @@ fn windowsCreateProcess(app_name: [*:0]u16, cmd_line: [*:0]u16, envp_ptr: ?[*]u1
776776

777777
/// Caller must dealloc.
778778
/// Guarantees a null byte at result[result.len].
779-
fn windowsCreateCommandLine(allocator: *mem.Allocator, argv: []const []const u8) ![]u8 {
779+
fn windowsCreateCommandLine(allocator: *mem.Allocator, argv: []const []const u8) ![:0]u8 {
780780
var buf = try Buffer.initSize(allocator, 0);
781781
defer buf.deinit();
782-
783-
var buf_stream = buf.outStream();
782+
const buf_stream = buf.outStream();
784783

785784
for (argv) |arg, arg_i| {
786-
if (arg_i != 0) try buf.appendByte(' ');
785+
if (arg_i != 0) try buf_stream.writeByte(' ');
787786
if (mem.indexOfAny(u8, arg, " \t\n\"") == null) {
788-
try buf.append(arg);
787+
try buf_stream.writeAll(arg);
789788
continue;
790789
}
791-
try buf.appendByte('"');
790+
try buf_stream.writeByte('"');
792791
var backslash_count: usize = 0;
793792
for (arg) |byte| {
794793
switch (byte) {
795794
'\\' => backslash_count += 1,
796795
'"' => {
797796
try buf_stream.writeByteNTimes('\\', backslash_count * 2 + 1);
798-
try buf.appendByte('"');
797+
try buf_stream.writeByte('"');
799798
backslash_count = 0;
800799
},
801800
else => {
802801
try buf_stream.writeByteNTimes('\\', backslash_count);
803-
try buf.appendByte(byte);
802+
try buf_stream.writeByte(byte);
804803
backslash_count = 0;
805804
},
806805
}
807806
}
808807
try buf_stream.writeByteNTimes('\\', backslash_count * 2);
809-
try buf.appendByte('"');
808+
try buf_stream.writeByte('"');
810809
}
811810

812811
return buf.toOwnedSlice();

0 commit comments

Comments
 (0)