mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-10-28 10:45:48 +08:00
Remove deprecated aliases of ArrayList and update usage sites.
This commit is contained in:
1 parent
d924f83bf3
commit
093d28dfae
11 files changed
+38
-44
No files matched your search
@@ -1119,11 +1119,11 @@ fn addCxxKnownPath(
|
||||
const arena = b.graph.arena;
|
||||
|
||||
const path_padded = run: {
|
||||
var args = std.array_list.Managed([]const u8).init(arena);
|
||||
try args.append(ctx.cxx_compiler);
|
||||
var args: std.ArrayList([]const u8) = .empty;
|
||||
try args.append(arena, ctx.cxx_compiler);
|
||||
var it = std.mem.tokenizeAny(u8, ctx.cxx_compiler_arg1, &std.ascii.whitespace);
|
||||
while (it.next()) |arg| try args.append(arg);
|
||||
try args.append(b.fmt("-print-file-name={s}", .{objname}));
|
||||
while (it.next()) |arg| try args.append(arena, arg);
|
||||
try args.append(arena, b.fmt("-print-file-name={s}", .{objname}));
|
||||
break :run b.run(args.items);
|
||||
};
|
||||
var tokenizer = mem.tokenizeAny(u8, path_padded, "\r\n");
|
||||
|
||||
@@ -46,7 +46,7 @@ var coverage = Coverage.init;
|
||||
/// Index of type `SourceLocationIndex`.
|
||||
var coverage_source_locations: std.ArrayList(Coverage.SourceLocation) = .empty;
|
||||
/// Contains the most recent coverage update message, unmodified.
|
||||
var recent_coverage_update: std.ArrayListAlignedUnmanaged(u8, .of(u64)) = .empty;
|
||||
var recent_coverage_update: std.array_list.Aligned(u8, .of(u64)) = .empty;
|
||||
|
||||
fn updateCoverageSources(
|
||||
directories: []const Coverage.String,
|
||||
|
||||
@@ -68,7 +68,7 @@ export fn alloc(n: usize) [*]u8 {
|
||||
return slice.ptr;
|
||||
}
|
||||
|
||||
var message_buffer: std.ArrayListAlignedUnmanaged(u8, .of(u64)) = .empty;
|
||||
var message_buffer: std.array_list.Aligned(u8, .of(u64)) = .empty;
|
||||
|
||||
/// Resizes the message buffer to be the correct length; returns the pointer to
|
||||
/// the query string.
|
||||
|
||||
+1
-1
@@ -2699,7 +2699,7 @@ const PragmaLoc = struct { name_tok: TokenWithExpansionLocs, start: Tree.TokenIn
|
||||
|
||||
fn addTokensFromExpandBuf(pp: *Preprocessor, tokens: []const TokenWithExpansionLocs, tokenizer_nl: TokenWithExpansionLocs) !void {
|
||||
const gpa = pp.comp.gpa;
|
||||
var pragma_locs: std.ArrayListUnmanaged(PragmaLoc) = .empty;
|
||||
var pragma_locs: std.ArrayList(PragmaLoc) = .empty;
|
||||
defer pragma_locs.deinit(gpa);
|
||||
|
||||
try pp.ensureUnusedTokenCapacity(tokens.len);
|
||||
|
||||
@@ -153,9 +153,9 @@ pub fn main(init: std.process.Init) !void {
|
||||
// result, restart the whole process, reparsing the AST and re-generating the list
|
||||
// of all possible transformations and shuffling it again.
|
||||
|
||||
var transformations = std.array_list.Managed(Walk.Transformation).init(gpa);
|
||||
defer transformations.deinit();
|
||||
try Walk.findTransformations(arena, &tree, &transformations);
|
||||
var transformations: std.ArrayList(Walk.Transformation) = .empty;
|
||||
defer transformations.deinit(gpa);
|
||||
try Walk.findTransformations(arena, gpa, &tree, &transformations);
|
||||
sortTransformations(transformations.items, rng.random());
|
||||
|
||||
fresh: while (transformations.items.len > 0) {
|
||||
@@ -238,7 +238,7 @@ pub fn main(init: std.process.Init) !void {
|
||||
tree.deinit(gpa);
|
||||
tree = new_tree;
|
||||
|
||||
try Walk.findTransformations(arena, &tree, &transformations);
|
||||
try Walk.findTransformations(arena, gpa, &tree, &transformations);
|
||||
sortTransformations(transformations.items, rng.random());
|
||||
|
||||
continue :fresh;
|
||||
|
||||
@@ -5,7 +5,7 @@ const assert = std.debug.assert;
|
||||
const BuiltinFn = std.zig.BuiltinFn;
|
||||
|
||||
ast: *const Ast,
|
||||
transformations: *std.array_list.Managed(Transformation),
|
||||
transformations: *std.ArrayList(Transformation),
|
||||
unreferenced_globals: std.array_hash_map.String(Ast.Node.Index),
|
||||
in_scope_names: std.array_hash_map.String(u32),
|
||||
replace_names: std.array_hash_map.String(u32),
|
||||
@@ -53,15 +53,16 @@ pub const Error = error{OutOfMemory};
|
||||
/// The result will be priority shuffled.
|
||||
pub fn findTransformations(
|
||||
arena: std.mem.Allocator,
|
||||
gpa: std.mem.Allocator,
|
||||
ast: *const Ast,
|
||||
transformations: *std.array_list.Managed(Transformation),
|
||||
transformations: *std.ArrayList(Transformation),
|
||||
) !void {
|
||||
transformations.clearRetainingCapacity();
|
||||
|
||||
var walk: Walk = .{
|
||||
.ast = ast,
|
||||
.transformations = transformations,
|
||||
.gpa = transformations.allocator,
|
||||
.gpa = gpa,
|
||||
.arena = arena,
|
||||
.unreferenced_globals = .empty,
|
||||
.in_scope_names = .empty,
|
||||
@@ -76,7 +77,7 @@ pub fn findTransformations(
|
||||
try walkMembers(&walk, walk.ast.rootDecls());
|
||||
|
||||
const unreferenced_globals = walk.unreferenced_globals.values();
|
||||
try transformations.ensureUnusedCapacity(unreferenced_globals.len);
|
||||
try transformations.ensureUnusedCapacity(gpa, unreferenced_globals.len);
|
||||
for (unreferenced_globals) |node| {
|
||||
transformations.appendAssumeCapacity(.{ .delete_node = node });
|
||||
}
|
||||
@@ -148,7 +149,7 @@ fn walkMember(w: *Walk, decl: Ast.Node.Index) Error!void {
|
||||
try walkExpression(w, fn_proto);
|
||||
if (!isFnBodyGutted(ast, body_node)) {
|
||||
w.replace_names.clearRetainingCapacity();
|
||||
try w.transformations.append(.{ .gut_function = decl });
|
||||
try w.transformations.append(w.gpa, .{ .gut_function = decl });
|
||||
try walkExpression(w, body_node);
|
||||
}
|
||||
},
|
||||
@@ -167,7 +168,7 @@ fn walkMember(w: *Walk, decl: Ast.Node.Index) Error!void {
|
||||
=> try walkGlobalVarDecl(w, decl, ast.fullVarDecl(decl).?),
|
||||
|
||||
.test_decl => {
|
||||
try w.transformations.append(.{ .delete_node = decl });
|
||||
try w.transformations.append(w.gpa, .{ .delete_node = decl });
|
||||
try walkExpression(w, ast.nodeData(decl).opt_token_and_node[1]);
|
||||
},
|
||||
|
||||
@@ -175,12 +176,12 @@ fn walkMember(w: *Walk, decl: Ast.Node.Index) Error!void {
|
||||
.container_field_align,
|
||||
.container_field,
|
||||
=> {
|
||||
try w.transformations.append(.{ .delete_node = decl });
|
||||
try w.transformations.append(w.gpa, .{ .delete_node = decl });
|
||||
try walkContainerField(w, ast.fullContainerField(decl).?);
|
||||
},
|
||||
|
||||
.@"comptime" => {
|
||||
try w.transformations.append(.{ .delete_node = decl });
|
||||
try w.transformations.append(w.gpa, .{ .delete_node = decl });
|
||||
try walkExpression(w, decl);
|
||||
},
|
||||
|
||||
@@ -536,7 +537,7 @@ fn walkGlobalVarDecl(w: *Walk, decl_node: Ast.Node.Index, var_decl: Ast.full.Var
|
||||
|
||||
if (var_decl.ast.init_node.unwrap()) |init_node| {
|
||||
if (!isUndefinedIdent(w.ast, init_node)) {
|
||||
try w.transformations.append(.{ .replace_with_undef = init_node });
|
||||
try w.transformations.append(w.gpa, .{ .replace_with_undef = init_node });
|
||||
}
|
||||
try walkExpression(w, init_node);
|
||||
}
|
||||
@@ -563,7 +564,7 @@ fn walkLocalVarDecl(w: *Walk, var_decl: Ast.full.VarDecl) Error!void {
|
||||
|
||||
if (var_decl.ast.init_node.unwrap()) |init_node| {
|
||||
if (!isUndefinedIdent(w.ast, init_node)) {
|
||||
try w.transformations.append(.{ .replace_with_undef = init_node });
|
||||
try w.transformations.append(w.gpa, .{ .replace_with_undef = init_node });
|
||||
}
|
||||
try walkExpression(w, init_node);
|
||||
}
|
||||
@@ -600,7 +601,7 @@ fn walkBlock(
|
||||
if (var_decl.ast.init_node != .none and
|
||||
isUndefinedIdent(w.ast, var_decl.ast.init_node.unwrap().?))
|
||||
{
|
||||
try w.transformations.append(.{ .delete_var_decl = .{
|
||||
try w.transformations.append(w.gpa, .{ .delete_var_decl = .{
|
||||
.var_decl_node = stmt,
|
||||
.references = .empty,
|
||||
} });
|
||||
@@ -618,7 +619,7 @@ fn walkBlock(
|
||||
.discard_identifier => {},
|
||||
// definitely try to remove `_ = undefined;` though.
|
||||
.discard_undefined, .trap_call, .other => {
|
||||
try w.transformations.append(.{ .delete_node = stmt });
|
||||
try w.transformations.append(w.gpa, .{ .delete_node = stmt });
|
||||
},
|
||||
}
|
||||
try walkExpression(w, stmt);
|
||||
@@ -720,7 +721,7 @@ fn walkBuiltinCall(
|
||||
if (std.mem.endsWith(u8, token_bytes, ".zig\"")) {
|
||||
const imported_string = std.zig.string_literal.parseAlloc(w.arena, token_bytes) catch
|
||||
unreachable;
|
||||
try w.transformations.append(.{ .inline_imported_file = .{
|
||||
try w.transformations.append(w.gpa, .{ .inline_imported_file = .{
|
||||
.builtin_call_node = call_node,
|
||||
.imported_string = imported_string,
|
||||
.in_scope_names = try std.array_hash_map.String(void).init(
|
||||
@@ -792,19 +793,19 @@ fn walkWhile(w: *Walk, node_index: Ast.Node.Index, while_node: Ast.full.While) E
|
||||
if (!isTrueIdent(w.ast, while_node.ast.cond_expr) and
|
||||
(while_node.ast.else_expr == .none or isEmptyBlock(w.ast, while_node.ast.else_expr.unwrap().?)))
|
||||
{
|
||||
try w.transformations.ensureUnusedCapacity(1);
|
||||
try w.transformations.ensureUnusedCapacity(w.gpa, 1);
|
||||
w.transformations.appendAssumeCapacity(.{ .replace_with_true = while_node.ast.cond_expr });
|
||||
} else if (!isFalseIdent(w.ast, while_node.ast.cond_expr) and isEmptyBlock(w.ast, while_node.ast.then_expr)) {
|
||||
try w.transformations.ensureUnusedCapacity(1);
|
||||
try w.transformations.ensureUnusedCapacity(w.gpa, 1);
|
||||
w.transformations.appendAssumeCapacity(.{ .replace_with_false = while_node.ast.cond_expr });
|
||||
} else if (isTrueIdent(w.ast, while_node.ast.cond_expr)) {
|
||||
try w.transformations.ensureUnusedCapacity(1);
|
||||
try w.transformations.ensureUnusedCapacity(w.gpa, 1);
|
||||
w.transformations.appendAssumeCapacity(.{ .replace_node = .{
|
||||
.to_replace = node_index,
|
||||
.replacement = while_node.ast.then_expr,
|
||||
} });
|
||||
} else if (isFalseIdent(w.ast, while_node.ast.cond_expr)) {
|
||||
try w.transformations.ensureUnusedCapacity(1);
|
||||
try w.transformations.ensureUnusedCapacity(w.gpa, 1);
|
||||
w.transformations.appendAssumeCapacity(.{ .replace_node = .{
|
||||
.to_replace = node_index,
|
||||
.replacement = while_node.ast.else_expr.unwrap().?,
|
||||
@@ -841,19 +842,19 @@ fn walkIf(w: *Walk, node_index: Ast.Node.Index, if_node: Ast.full.If) Error!void
|
||||
if (!isTrueIdent(w.ast, if_node.ast.cond_expr) and
|
||||
(if_node.ast.else_expr == .none or isEmptyBlock(w.ast, if_node.ast.else_expr.unwrap().?)))
|
||||
{
|
||||
try w.transformations.ensureUnusedCapacity(1);
|
||||
try w.transformations.ensureUnusedCapacity(w.gpa, 1);
|
||||
w.transformations.appendAssumeCapacity(.{ .replace_with_true = if_node.ast.cond_expr });
|
||||
} else if (!isFalseIdent(w.ast, if_node.ast.cond_expr) and isEmptyBlock(w.ast, if_node.ast.then_expr)) {
|
||||
try w.transformations.ensureUnusedCapacity(1);
|
||||
try w.transformations.ensureUnusedCapacity(w.gpa, 1);
|
||||
w.transformations.appendAssumeCapacity(.{ .replace_with_false = if_node.ast.cond_expr });
|
||||
} else if (isTrueIdent(w.ast, if_node.ast.cond_expr)) {
|
||||
try w.transformations.ensureUnusedCapacity(1);
|
||||
try w.transformations.ensureUnusedCapacity(w.gpa, 1);
|
||||
w.transformations.appendAssumeCapacity(.{ .replace_node = .{
|
||||
.to_replace = node_index,
|
||||
.replacement = if_node.ast.then_expr,
|
||||
} });
|
||||
} else if (isFalseIdent(w.ast, if_node.ast.cond_expr)) {
|
||||
try w.transformations.ensureUnusedCapacity(1);
|
||||
try w.transformations.ensureUnusedCapacity(w.gpa, 1);
|
||||
w.transformations.appendAssumeCapacity(.{ .replace_node = .{
|
||||
.to_replace = node_index,
|
||||
.replacement = if_node.ast.else_expr.unwrap().?,
|
||||
|
||||
@@ -32,7 +32,7 @@ pub const Annotation = struct {
|
||||
|
||||
pub fn fileSourceLineNumbersHtml(
|
||||
file_index: Walk.File.Index,
|
||||
out: *std.ArrayListUnmanaged(u8),
|
||||
out: *std.ArrayList(u8),
|
||||
root_node: Ast.Node.Index,
|
||||
) !void {
|
||||
const ast = file_index.get_ast();
|
||||
|
||||
@@ -12,7 +12,7 @@ const mem = std.mem;
|
||||
const phc_format = pwhash.phc_format;
|
||||
const pwhash = crypto.pwhash;
|
||||
const Blake2b512 = blake2.Blake2b512;
|
||||
const Blocks = std.array_list.AlignedManaged([block_length]u64, .@"16");
|
||||
const Blocks = std.array_list.Aligned([block_length]u64, .@"16");
|
||||
const H0 = [Blake2b512.digest_length + 8]u8;
|
||||
|
||||
const EncodingError = crypto.errors.EncodingError;
|
||||
@@ -504,7 +504,7 @@ pub fn kdf(
|
||||
const memory = blockCount(params);
|
||||
|
||||
var blocks = try Blocks.initCapacity(allocator, memory);
|
||||
defer blocks.deinit();
|
||||
defer blocks.deinit(allocator);
|
||||
|
||||
const items = blocks.addManyAsSliceAssumeCapacity(memory);
|
||||
|
||||
|
||||
@@ -54,13 +54,6 @@ pub fn ArrayList(comptime T: type) type {
|
||||
}
|
||||
pub const array_list = @import("array_list.zig");
|
||||
|
||||
/// Deprecated; use `array_list.Aligned`.
|
||||
pub const ArrayListAligned = array_list.Aligned;
|
||||
/// Deprecated; use `array_list.Aligned`.
|
||||
pub const ArrayListAlignedUnmanaged = array_list.Aligned;
|
||||
/// Deprecated; use `ArrayList`.
|
||||
pub const ArrayListUnmanaged = ArrayList;
|
||||
|
||||
pub const array_hash_map = @import("array_hash_map.zig");
|
||||
pub const atomic = @import("atomic.zig");
|
||||
pub const base64 = @import("base64.zig");
|
||||
|
||||
@@ -21,7 +21,7 @@ owner_nav: InternPool.Nav.Index,
|
||||
func_index: InternPool.Index,
|
||||
mir_instructions: std.MultiArrayList(Mir.Inst),
|
||||
/// Contains extra data for MIR
|
||||
mir_extra: std.ArrayListUnmanaged(u32),
|
||||
mir_extra: std.ArrayList(u32),
|
||||
|
||||
pub fn legalizeFeatures(_: *const std.Target) *const Air.Legalize.Features {
|
||||
return comptime &.initMany(&.{
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ base: link.File,
|
||||
/// All MIR instructions for all Zcu functions.
|
||||
mir_instructions: std.MultiArrayList(Mir.Inst) = .empty,
|
||||
/// Corresponds to `mir_instructions`.
|
||||
mir_extra: std.ArrayListUnmanaged(u32) = .empty,
|
||||
mir_extra: std.ArrayList(u32) = .empty,
|
||||
/// When the key is an enum type, this represents a `@tagName` function.
|
||||
zcu_funcs: std.array_hash_map.Auto(InternPool.Index, ZcuFunc) = .empty,
|
||||
|
||||
|
||||
Reference in new issue
Block a user