Skip to content

Commit 0398c26

Browse files
committed
std: use std.ArrayList(u8) instead of std.Buffer in std/child_process.zig
1 parent 47071e9 commit 0398c26

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

lib/std/child_process.zig

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const windows = os.windows;
1010
const mem = std.mem;
1111
const debug = std.debug;
1212
const BufMap = std.BufMap;
13-
const Buffer = std.Buffer;
1413
const builtin = @import("builtin");
1514
const Os = builtin.Os;
1615
const TailQueue = std.TailQueue;
@@ -777,36 +776,36 @@ fn windowsCreateProcess(app_name: [*:0]u16, cmd_line: [*:0]u16, envp_ptr: ?[*]u1
777776
/// Caller must dealloc.
778777
/// Guarantees a null byte at result[result.len].
779778
fn windowsCreateCommandLine(allocator: *mem.Allocator, argv: []const []const u8) ![]u8 {
780-
var buf = try Buffer.initSize(allocator, 0);
779+
var buf = std.ArrayList(u8).init(allocator);
781780
defer buf.deinit();
782781

783782
var 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.append(' ');
787786
if (mem.indexOfAny(u8, arg, " \t\n\"") == null) {
788-
try buf.append(arg);
787+
try buf.appendSlice(arg);
789788
continue;
790789
}
791-
try buf.appendByte('"');
790+
try buf.append('"');
792791
var backslash_count: usize = 0;
793792
for (arg) |byte| {
794793
switch (byte) {
795794
'\\' => backslash_count += 1,
796795
'"' => {
797-
try buf_stream.writeByteNTimes('\\', backslash_count * 2 + 1);
798-
try buf.appendByte('"');
796+
try buf.appendNTimes('\\', backslash_count * 2 + 1);
797+
try buf.append('"');
799798
backslash_count = 0;
800799
},
801800
else => {
802-
try buf_stream.writeByteNTimes('\\', backslash_count);
803-
try buf.appendByte(byte);
801+
try buf.appendNTimes('\\', backslash_count);
802+
try buf.append(byte);
804803
backslash_count = 0;
805804
},
806805
}
807806
}
808-
try buf_stream.writeByteNTimes('\\', backslash_count * 2);
809-
try buf.appendByte('"');
807+
try buf.appendNTimes('\\', backslash_count * 2);
808+
try buf.append('"');
810809
}
811810

812811
return buf.toOwnedSlice();

0 commit comments

Comments
 (0)