From b5ed0ae2cecb96adca7b259f7054519c92a3283f Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Fri, 23 Oct 2026 09:03:25 +0200 Subject: [PATCH] Remove usages of array_list.Managed in lib/compiler/Maker --- lib/compiler/Maker.zig | 19 +++++++++++-------- lib/compiler/Maker/Fetch.zig | 12 ++++++------ lib/compiler/Maker/Step/Compile.zig | 2 +- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/compiler/Maker.zig b/lib/compiler/Maker.zig index e0ce8142628ad4aac0466293869eaa9f7bab225d..d4f9723fcb4c6315faaa74e6e24e785d2942ac8d 100644 --- a/lib/compiler/Maker.zig +++ b/lib/compiler/Maker.zig @@ -4677,12 +4677,13 @@ test sanitizeExampleName { const Templates = struct { zig_lib_directory: Cache.Directory, dir: Io.Dir, - buffer: std.array_list.Managed(u8), + buffer: std.ArrayList(u8), + gpa: Allocator, fn deinit(templates: *Templates, io: Io) void { templates.zig_lib_directory.handle.close(io); templates.dir.close(io); - templates.buffer.deinit(); + templates.buffer.deinit(templates.gpa); templates.* = undefined; } @@ -4705,29 +4706,30 @@ const Templates = struct { const contents = templates.dir.readFileAlloc(io, template_path, arena, .limited(max_bytes)) catch |err| { fatal("unable to read template file {q}: {t}", .{ template_path, err }); }; + const gpa = templates.gpa; templates.buffer.clearRetainingCapacity(); - try templates.buffer.ensureUnusedCapacity(contents.len); + try templates.buffer.ensureUnusedCapacity(gpa, contents.len); var i: usize = 0; while (i < contents.len) { if (contents[i] == '_' or contents[i] == '.') { // Both '_' and '.' are allowed because depending on the context // one prefix will be valid, while the other might not. if (std.mem.startsWith(u8, contents[i + 1 ..], "NAME")) { - try templates.buffer.appendSlice(root_name); + try templates.buffer.appendSlice(gpa, root_name); i += "_NAME".len; continue; } else if (std.mem.startsWith(u8, contents[i + 1 ..], "FINGERPRINT")) { - try templates.buffer.print("0x{x}", .{fingerprint.int()}); + try templates.buffer.print(gpa, "0x{x}", .{fingerprint.int()}); i += "_FINGERPRINT".len; continue; } else if (std.mem.startsWith(u8, contents[i + 1 ..], "ZIGVER")) { - try templates.buffer.appendSlice(builtin.zig_version_string); + try templates.buffer.appendSlice(gpa, builtin.zig_version_string); i += "_ZIGVER".len; continue; } } - try templates.buffer.append(contents[i]); + try templates.buffer.append(gpa, contents[i]); i += 1; } @@ -4748,7 +4750,8 @@ const Templates = struct { return .{ .zig_lib_directory = zig_lib_directory, .dir = template_dir, - .buffer = std.array_list.Managed(u8).init(gpa), + .buffer = .empty, + .gpa = gpa, }; } diff --git a/lib/compiler/Maker/Fetch.zig b/lib/compiler/Maker/Fetch.zig index c1bc153056854864050ef8a0656255b2541b57a5..a376f96a61805b6bad5185a556eaa5b1f6fe9133 100644 --- a/lib/compiler/Maker/Fetch.zig +++ b/lib/compiler/Maker/Fetch.zig @@ -1756,11 +1756,11 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash const root_dir = pkg_path.root_dir.handle; // Collect all files, recursively, then sort. - var all_files = std.array_list.Managed(*HashedFile).init(gpa); - defer all_files.deinit(); + var all_files: std.ArrayList(*HashedFile) = .empty; + defer all_files.deinit(gpa); - var deleted_files = std.array_list.Managed(*DeletedFile).init(gpa); - defer deleted_files.deinit(); + var deleted_files: std.ArrayList(*DeletedFile) = .empty; + defer deleted_files.deinit(gpa); // Track directories which had any files deleted from them so that empty directories // can be deleted. @@ -1803,7 +1803,7 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash .failure = undefined, // to be populated by the worker }; group.async(io, workerDeleteFile, .{ io, root_dir, deleted_file }); - try deleted_files.append(deleted_file); + try deleted_files.append(gpa, deleted_file); continue; } @@ -1831,7 +1831,7 @@ fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash .size = undefined, // to be populated by the worker }; group.async(io, workerHashFile, .{ io, root_dir, hashed_file }); - try all_files.append(hashed_file); + try all_files.append(gpa, hashed_file); } try group.await(io); diff --git a/lib/compiler/Maker/Step/Compile.zig b/lib/compiler/Maker/Step/Compile.zig index 8c6ab5fe30c55becc28af17276c89b3f4baca121..396af76a5e9cfb70bc841f8f4d2405785d7eb67f 100644 --- a/lib/compiler/Maker/Step/Compile.zig +++ b/lib/compiler/Maker/Step/Compile.zig @@ -867,7 +867,7 @@ fn lowerZigArgs( return step.fail(maker, "failed creating directory {f}: {t}", .{ args_path, err }); const args_to_escape = zig_args.items[2..]; - var escaped_args = try std.array_list.Managed([]const u8).initCapacity(arena, args_to_escape.len); + var escaped_args: std.ArrayList([]const u8) = try .initCapacity(arena, args_to_escape.len); arg_blk: for (args_to_escape) |arg| { for (arg, 0..) |c, arg_idx| { if (c == '\\' or c == '"') { -- 2.54.0