authorgravatar for der.teufel.mail@gmail.comKrzysztof Wolicki <der.teufel.mail@gmail.com> 2026-10-23 09:03:25+02:00
committergravatar for der.teufel.mail@gmail.comKrzysztof Wolicki <der.teufel.mail@gmail.com> 2026-10-23 09:03:25+02:00
logb5ed0ae2cecb96adca7b259f7054519c92a3283f
treeef5e9ef53e900fd3b4ffd0e7db8a79b06bb2e2b4
parentfb255db0adc7fb39f4d33738fcf3c5831a1a7649

Remove usages of array_list.Managed in lib/compiler/Maker


3 files changed, 18 insertions(+), 15 deletions(-)

lib/compiler/Maker.zig+11-8
...@@ -4677,12 +4677,13 @@ test sanitizeExampleName {...@@ -4677,12 +4677,13 @@ test sanitizeExampleName {
4677const Templates = struct {4677const Templates = struct {
4678 zig_lib_directory: Cache.Directory,4678 zig_lib_directory: Cache.Directory,
4679 dir: Io.Dir,4679 dir: Io.Dir,
4680 buffer: std.array_list.Managed(u8),4680 buffer: std.ArrayList(u8),
4681 gpa: Allocator,
46814682
4682 fn deinit(templates: *Templates, io: Io) void {4683 fn deinit(templates: *Templates, io: Io) void {
4683 templates.zig_lib_directory.handle.close(io);4684 templates.zig_lib_directory.handle.close(io);
4684 templates.dir.close(io);4685 templates.dir.close(io);
4685 templates.buffer.deinit();4686 templates.buffer.deinit(templates.gpa);
4686 templates.* = undefined;4687 templates.* = undefined;
4687 }4688 }
46884689
...@@ -4705,29 +4706,30 @@ const Templates = struct {...@@ -4705,29 +4706,30 @@ const Templates = struct {
4705 const contents = templates.dir.readFileAlloc(io, template_path, arena, .limited(max_bytes)) catch |err| {4706 const contents = templates.dir.readFileAlloc(io, template_path, arena, .limited(max_bytes)) catch |err| {
4706 fatal("unable to read template file {q}: {t}", .{ template_path, err });4707 fatal("unable to read template file {q}: {t}", .{ template_path, err });
4707 };4708 };
4709 const gpa = templates.gpa;
4708 templates.buffer.clearRetainingCapacity();4710 templates.buffer.clearRetainingCapacity();
4709 try templates.buffer.ensureUnusedCapacity(contents.len);4711 try templates.buffer.ensureUnusedCapacity(gpa, contents.len);
4710 var i: usize = 0;4712 var i: usize = 0;
4711 while (i < contents.len) {4713 while (i < contents.len) {
4712 if (contents[i] == '_' or contents[i] == '.') {4714 if (contents[i] == '_' or contents[i] == '.') {
4713 // Both '_' and '.' are allowed because depending on the context4715 // Both '_' and '.' are allowed because depending on the context
4714 // one prefix will be valid, while the other might not.4716 // one prefix will be valid, while the other might not.
4715 if (std.mem.startsWith(u8, contents[i + 1 ..], "NAME")) {4717 if (std.mem.startsWith(u8, contents[i + 1 ..], "NAME")) {
4716 try templates.buffer.appendSlice(root_name);4718 try templates.buffer.appendSlice(gpa, root_name);
4717 i += "_NAME".len;4719 i += "_NAME".len;
4718 continue;4720 continue;
4719 } else if (std.mem.startsWith(u8, contents[i + 1 ..], "FINGERPRINT")) {4721 } else if (std.mem.startsWith(u8, contents[i + 1 ..], "FINGERPRINT")) {
4720 try templates.buffer.print("0x{x}", .{fingerprint.int()});4722 try templates.buffer.print(gpa, "0x{x}", .{fingerprint.int()});
4721 i += "_FINGERPRINT".len;4723 i += "_FINGERPRINT".len;
4722 continue;4724 continue;
4723 } else if (std.mem.startsWith(u8, contents[i + 1 ..], "ZIGVER")) {4725 } else if (std.mem.startsWith(u8, contents[i + 1 ..], "ZIGVER")) {
4724 try templates.buffer.appendSlice(builtin.zig_version_string);4726 try templates.buffer.appendSlice(gpa, builtin.zig_version_string);
4725 i += "_ZIGVER".len;4727 i += "_ZIGVER".len;
4726 continue;4728 continue;
4727 }4729 }
4728 }4730 }
47294731
4730 try templates.buffer.append(contents[i]);4732 try templates.buffer.append(gpa, contents[i]);
4731 i += 1;4733 i += 1;
4732 }4734 }
47334735
...@@ -4748,7 +4750,8 @@ const Templates = struct {...@@ -4748,7 +4750,8 @@ const Templates = struct {
4748 return .{4750 return .{
4749 .zig_lib_directory = zig_lib_directory,4751 .zig_lib_directory = zig_lib_directory,
4750 .dir = template_dir,4752 .dir = template_dir,
4751 .buffer = std.array_list.Managed(u8).init(gpa),4753 .buffer = .empty,
4754 .gpa = gpa,
4752 };4755 };
4753 }4756 }
47544757
lib/compiler/Maker/Fetch.zig+6-6
...@@ -1756,11 +1756,11 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash...@@ -1756,11 +1756,11 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash
1756 const root_dir = pkg_path.root_dir.handle;1756 const root_dir = pkg_path.root_dir.handle;
17571757
1758 // Collect all files, recursively, then sort.1758 // Collect all files, recursively, then sort.
1759 var all_files = std.array_list.Managed(*HashedFile).init(gpa);1759 var all_files: std.ArrayList(*HashedFile) = .empty;
1760 defer all_files.deinit();1760 defer all_files.deinit(gpa);
17611761
1762 var deleted_files = std.array_list.Managed(*DeletedFile).init(gpa);1762 var deleted_files: std.ArrayList(*DeletedFile) = .empty;
1763 defer deleted_files.deinit();1763 defer deleted_files.deinit(gpa);
17641764
1765 // Track directories which had any files deleted from them so that empty directories1765 // Track directories which had any files deleted from them so that empty directories
1766 // can be deleted.1766 // can be deleted.
...@@ -1803,7 +1803,7 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash...@@ -1803,7 +1803,7 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash
1803 .failure = undefined, // to be populated by the worker1803 .failure = undefined, // to be populated by the worker
1804 };1804 };
1805 group.async(io, workerDeleteFile, .{ io, root_dir, deleted_file });1805 group.async(io, workerDeleteFile, .{ io, root_dir, deleted_file });
1806 try deleted_files.append(deleted_file);1806 try deleted_files.append(gpa, deleted_file);
1807 continue;1807 continue;
1808 }1808 }
18091809
...@@ -1831,7 +1831,7 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash...@@ -1831,7 +1831,7 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash
1831 .size = undefined, // to be populated by the worker1831 .size = undefined, // to be populated by the worker
1832 };1832 };
1833 group.async(io, workerHashFile, .{ io, root_dir, hashed_file });1833 group.async(io, workerHashFile, .{ io, root_dir, hashed_file });
1834 try all_files.append(hashed_file);1834 try all_files.append(gpa, hashed_file);
1835 }1835 }
18361836
1837 try group.await(io);1837 try group.await(io);
lib/compiler/Maker/Step/Compile.zig+1-1
...@@ -867,7 +867,7 @@ fn lowerZigArgs(...@@ -867,7 +867,7 @@ fn lowerZigArgs(
867 return step.fail(maker, "failed creating directory {f}: {t}", .{ args_path, err });867 return step.fail(maker, "failed creating directory {f}: {t}", .{ args_path, err });
868868
869 const args_to_escape = zig_args.items[2..];869 const args_to_escape = zig_args.items[2..];
870 var escaped_args = try std.array_list.Managed([]const u8).initCapacity(arena, args_to_escape.len);870 var escaped_args: std.ArrayList([]const u8) = try .initCapacity(arena, args_to_escape.len);
871 arg_blk: for (args_to_escape) |arg| {871 arg_blk: for (args_to_escape) |arg| {
872 for (arg, 0..) |c, arg_idx| {872 for (arg, 0..) |c, arg_idx| {
873 if (c == '\\' or c == '"') {873 if (c == '\\' or c == '"') {