Skip to content

Commit 91d9898

Browse files
committed
std: use std.ArrayList(u8).OutStream instead of std.Buffer.OutStream
1 parent 00f2c25 commit 91d9898

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

doc/docgen.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
321321
var last_action = Action.Open;
322322
var last_columns: ?u8 = null;
323323

324-
var toc_buf = try std.Buffer.initSize(allocator, 0);
324+
var toc_buf = std.ArrayList(u8).init(allocator);
325325
defer toc_buf.deinit();
326326

327327
var toc = toc_buf.outStream();
@@ -607,7 +607,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
607607
}
608608

609609
fn urlize(allocator: *mem.Allocator, input: []const u8) ![]u8 {
610-
var buf = try std.Buffer.initSize(allocator, 0);
610+
var buf = std.ArrayList(u8).init(allocator);
611611
defer buf.deinit();
612612

613613
const out = buf.outStream();
@@ -626,7 +626,7 @@ fn urlize(allocator: *mem.Allocator, input: []const u8) ![]u8 {
626626
}
627627

628628
fn escapeHtml(allocator: *mem.Allocator, input: []const u8) ![]u8 {
629-
var buf = try std.Buffer.initSize(allocator, 0);
629+
var buf = std.ArrayList(u8).init(allocator);
630630
defer buf.deinit();
631631

632632
const out = buf.outStream();
@@ -672,7 +672,7 @@ test "term color" {
672672
}
673673

674674
fn termColor(allocator: *mem.Allocator, input: []const u8) ![]u8 {
675-
var buf = try std.Buffer.initSize(allocator, 0);
675+
var buf = std.ArrayList(u8).init(allocator);
676676
defer buf.deinit();
677677

678678
var out = buf.outStream();

lib/std/zig/parser_test.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2924,7 +2924,7 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b
29242924
return error.ParseError;
29252925
}
29262926

2927-
var buffer = try std.Buffer.initSize(allocator, 0);
2927+
var buffer = std.ArrayList(u8).init(allocator);
29282928
errdefer buffer.deinit();
29292929

29302930
anything_changed.* = try std.zig.render(allocator, buffer.outStream(), tree);

src-self-hosted/errmsg.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub const Msg = struct {
158158
parse_error: *const ast.Error,
159159
) !*Msg {
160160
const loc_token = parse_error.loc();
161-
var text_buf = try std.Buffer.initSize(comp.gpa(), 0);
161+
var text_buf = std.ArrayList(u8).init(comp.gpa());
162162
defer text_buf.deinit();
163163

164164
const realpath_copy = try mem.dupe(comp.gpa(), u8, tree_scope.root().realpath);
@@ -197,7 +197,7 @@ pub const Msg = struct {
197197
realpath: []const u8,
198198
) !*Msg {
199199
const loc_token = parse_error.loc();
200-
var text_buf = try std.Buffer.initSize(allocator, 0);
200+
var text_buf = std.ArrayList(u8).init(allocator);
201201
defer text_buf.deinit();
202202

203203
const realpath_copy = try mem.dupe(allocator, u8, realpath);

src-self-hosted/stage2.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,11 @@ fn printErrMsgToFile(
410410
const start_loc = tree.tokenLocationPtr(0, first_token);
411411
const end_loc = tree.tokenLocationPtr(first_token.end, last_token);
412412

413-
var text_buf = try std.Buffer.initSize(allocator, 0);
413+
var text_buf = std.ArrayList(u8).init(allocator);
414+
defer text_buf.deinit();
414415
const out_stream = &text_buf.outStream();
415416
try parse_error.render(&tree.tokens, out_stream);
416-
const text = text_buf.toOwnedSlice();
417+
const text = text_buf.span();
417418

418419
const stream = &file.outStream();
419420
try stream.print("{}:{}:{}: error: {}\n", .{ path, start_loc.line + 1, start_loc.column + 1, text });

src-self-hosted/type.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,10 @@ pub const Type = struct {
387387
};
388388
errdefer comp.gpa().destroy(self);
389389

390-
var name_buf = try std.Buffer.initSize(comp.gpa(), 0);
390+
var name_buf = std.ArrayList(u8).init(comp.gpa());
391391
defer name_buf.deinit();
392392

393-
const name_stream = &std.io.BufferOutStream.init(&name_buf).stream;
393+
const name_stream = name_buf.outStream();
394394

395395
switch (key.data) {
396396
.Generic => |generic| {

0 commit comments

Comments
 (0)