Skip to content
This repository was archived by the owner on Jan 6, 2026. It is now read-only.

Commit d62c75f

Browse files
committed
Use default named values where appropriate
1 parent 528df00 commit d62c75f

File tree

14 files changed

+98
-80
lines changed

14 files changed

+98
-80
lines changed

src/Archive.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
objects: std.ArrayListUnmanaged(Object) = .{},
1+
objects: std.ArrayListUnmanaged(Object) = .empty,
22

33
// Archive files start with the ARMAG identifying string. Then follows a
44
// `struct ar_hdr', and as many bytes of member file data as its `ar_size'

src/Atom.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ n_sect: u32 = 0,
2323
value: u64 = 0,
2424

2525
/// Name of this Atom.
26-
name: MachO.String = .{},
26+
name: MachO.String = .init,
2727

2828
/// Index of the output section.
2929
out_n_sect: u8 = 0,

src/CodeSignature.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const CodeDirectory = struct {
5252
inner: macho.CodeDirectory,
5353
ident: []const u8,
5454
special_slots: [n_special_slots][hash_size]u8,
55-
code_slots: std.ArrayListUnmanaged([hash_size]u8) = .{},
55+
code_slots: std.ArrayListUnmanaged([hash_size]u8) = .empty,
5656

5757
const n_special_slots: usize = 7;
5858

src/Dylib.zig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ index: File.Index,
55
file_handle: ?File.HandleIndex = null,
66
lib_stub: ?LibStub = null,
77

8-
exports: std.MultiArrayList(Export) = .{},
9-
strtab: std.ArrayListUnmanaged(u8) = .{},
8+
exports: std.MultiArrayList(Export) = .empty,
9+
strtab: std.ArrayListUnmanaged(u8) = .empty,
1010
id: ?Id = null,
1111
ordinal: u16 = 0,
1212

13-
symbols: std.ArrayListUnmanaged(Symbol) = .{},
14-
symbols_extra: std.ArrayListUnmanaged(u32) = .{},
15-
globals: std.ArrayListUnmanaged(MachO.SymbolResolver.Index) = .{},
16-
dependents: std.ArrayListUnmanaged(Id) = .{},
17-
rpaths: std.StringArrayHashMapUnmanaged(void) = .{},
13+
symbols: std.ArrayListUnmanaged(Symbol) = .empty,
14+
symbols_extra: std.ArrayListUnmanaged(u32) = .empty,
15+
globals: std.ArrayListUnmanaged(MachO.SymbolResolver.Index) = .empty,
16+
dependents: std.ArrayListUnmanaged(Id) = .empty,
17+
rpaths: std.StringArrayHashMapUnmanaged(void) = .empty,
1818
umbrella: File.Index,
1919

2020
needed: bool,
@@ -24,7 +24,7 @@ explicit: bool,
2424
hoisted: bool = true,
2525
referenced: bool = false,
2626

27-
output_symtab_ctx: MachO.SymtabCtx = .{},
27+
output_symtab_ctx: MachO.SymtabCtx = .init,
2828

2929
pub fn deinit(self: *Dylib, allocator: Allocator) void {
3030
if (self.lib_stub) |*ls| ls.deinit();

src/InternalObject.zig

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
index: File.Index,
22

3-
sections: std.MultiArrayList(Section) = .{},
4-
atoms: std.ArrayListUnmanaged(Atom) = .{},
5-
atoms_indexes: std.ArrayListUnmanaged(Atom.Index) = .{},
6-
atoms_extra: std.ArrayListUnmanaged(u32) = .{},
7-
symtab: std.ArrayListUnmanaged(macho.nlist_64) = .{},
8-
strtab: std.ArrayListUnmanaged(u8) = .{},
9-
symbols: std.ArrayListUnmanaged(Symbol) = .{},
10-
symbols_extra: std.ArrayListUnmanaged(u32) = .{},
11-
globals: std.ArrayListUnmanaged(MachO.SymbolResolver.Index) = .{},
12-
13-
objc_methnames: std.ArrayListUnmanaged(u8) = .{},
3+
sections: std.MultiArrayList(Section) = .empty,
4+
atoms: std.ArrayListUnmanaged(Atom) = .empty,
5+
atoms_indexes: std.ArrayListUnmanaged(Atom.Index) = .empty,
6+
atoms_extra: std.ArrayListUnmanaged(u32) = .empty,
7+
symtab: std.ArrayListUnmanaged(macho.nlist_64) = .empty,
8+
strtab: std.ArrayListUnmanaged(u8) = .empty,
9+
symbols: std.ArrayListUnmanaged(Symbol) = .empty,
10+
symbols_extra: std.ArrayListUnmanaged(u32) = .empty,
11+
globals: std.ArrayListUnmanaged(MachO.SymbolResolver.Index) = .empty,
12+
13+
objc_methnames: std.ArrayListUnmanaged(u8) = .empty,
1414
objc_selrefs: [@sizeOf(u64)]u8 = [_]u8{0} ** @sizeOf(u64),
1515

16-
force_undefined: std.ArrayListUnmanaged(Symbol.Index) = .{},
16+
force_undefined: std.ArrayListUnmanaged(Symbol.Index) = .empty,
1717
entry_index: ?Symbol.Index = null,
1818
dyld_stub_binder_index: ?Symbol.Index = null,
1919
dyld_private_index: ?Symbol.Index = null,
2020
objc_msg_send_index: ?Symbol.Index = null,
2121
mh_execute_header_index: ?Symbol.Index = null,
2222
mh_dylib_header_index: ?Symbol.Index = null,
2323
dso_handle_index: ?Symbol.Index = null,
24-
boundary_symbols: std.ArrayListUnmanaged(Symbol.Index) = .{},
24+
boundary_symbols: std.ArrayListUnmanaged(Symbol.Index) = .empty,
2525

26-
output_symtab_ctx: MachO.SymtabCtx = .{},
26+
output_symtab_ctx: MachO.SymtabCtx = .init,
2727

2828
pub fn deinit(self: *InternalObject, allocator: Allocator) void {
2929
for (self.sections.items(.relocs)) |*relocs| {

src/MachO.zig

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ file: fs.File,
33
thread_pool: *ThreadPool,
44
options: Options,
55

6-
warnings: std.ArrayListUnmanaged(ErrorMsg) = .{},
6+
warnings: std.ArrayListUnmanaged(ErrorMsg) = .empty,
77
warnings_mutex: std.Thread.Mutex = .{},
8-
errors: std.ArrayListUnmanaged(ErrorMsg) = .{},
8+
errors: std.ArrayListUnmanaged(ErrorMsg) = .empty,
99
errors_mutex: std.Thread.Mutex = .{},
1010

1111
dyld_info_cmd: macho.dyld_info_command = .{},
@@ -3235,16 +3235,29 @@ const Section = struct {
32353235
};
32363236

32373237
pub const SymtabCtx = struct {
3238-
ilocal: u32 = 0,
3239-
istab: u32 = 0,
3240-
iexport: u32 = 0,
3241-
iimport: u32 = 0,
3242-
nlocals: u32 = 0,
3243-
nstabs: u32 = 0,
3244-
nexports: u32 = 0,
3245-
nimports: u32 = 0,
3246-
stroff: u32 = 0,
3247-
strsize: u32 = 0,
3238+
ilocal: u32,
3239+
istab: u32,
3240+
iexport: u32,
3241+
iimport: u32,
3242+
nlocals: u32,
3243+
nstabs: u32,
3244+
nexports: u32,
3245+
nimports: u32,
3246+
stroff: u32,
3247+
strsize: u32,
3248+
3249+
pub const init: SymtabCtx = .{
3250+
.ilocal = 0,
3251+
.istab = 0,
3252+
.iexport = 0,
3253+
.iimport = 0,
3254+
.nlocals = 0,
3255+
.nstabs = 0,
3256+
.nexports = 0,
3257+
.nimports = 0,
3258+
.stroff = 0,
3259+
.strsize = 0,
3260+
};
32483261
};
32493262

32503263
pub const null_sym = macho.nlist_64{
@@ -3365,8 +3378,13 @@ pub const UndefRefs = union(enum) {
33653378
};
33663379

33673380
pub const String = struct {
3368-
pos: u32 = 0,
3369-
len: u32 = 0,
3381+
pos: u32,
3382+
len: u32,
3383+
3384+
pub const init: String = .{
3385+
.pos = 0,
3386+
.len = 0,
3387+
};
33703388
};
33713389

33723390
pub const ErrorMsg = struct {

src/Object.zig

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,34 @@ index: File.Index,
77
ar_name: ?[]const u8 = null,
88

99
header: ?macho.mach_header_64 = null,
10-
sections: std.MultiArrayList(Section) = .{},
11-
symtab: std.MultiArrayList(Nlist) = .{},
12-
strtab: std.ArrayListUnmanaged(u8) = .{},
10+
sections: std.MultiArrayList(Section) = .empty,
11+
symtab: std.MultiArrayList(Nlist) = .empty,
12+
strtab: std.ArrayListUnmanaged(u8) = .empty,
1313

14-
symbols: std.ArrayListUnmanaged(Symbol) = .{},
15-
symbols_extra: std.ArrayListUnmanaged(u32) = .{},
16-
globals: std.ArrayListUnmanaged(MachO.SymbolResolver.Index) = .{},
17-
atoms: std.ArrayListUnmanaged(Atom) = .{},
18-
atoms_indexes: std.ArrayListUnmanaged(Atom.Index) = .{},
19-
atoms_extra: std.ArrayListUnmanaged(u32) = .{},
14+
symbols: std.ArrayListUnmanaged(Symbol) = .empty,
15+
symbols_extra: std.ArrayListUnmanaged(u32) = .empty,
16+
globals: std.ArrayListUnmanaged(MachO.SymbolResolver.Index) = .empty,
17+
atoms: std.ArrayListUnmanaged(Atom) = .empty,
18+
atoms_indexes: std.ArrayListUnmanaged(Atom.Index) = .empty,
19+
atoms_extra: std.ArrayListUnmanaged(u32) = .empty,
2020

2121
compile_unit: ?CompileUnit = null,
22-
stab_files: std.ArrayListUnmanaged(StabFile) = .{},
22+
stab_files: std.ArrayListUnmanaged(StabFile) = .empty,
2323

2424
eh_frame_sect_index: ?u8 = null,
2525
compact_unwind_sect_index: ?u8 = null,
26-
cies: std.ArrayListUnmanaged(Cie) = .{},
27-
fdes: std.ArrayListUnmanaged(Fde) = .{},
28-
eh_frame_data: std.ArrayListUnmanaged(u8) = .{},
29-
unwind_records: std.ArrayListUnmanaged(UnwindInfo.Record) = .{},
30-
unwind_records_indexes: std.ArrayListUnmanaged(UnwindInfo.Record.Index) = .{},
31-
data_in_code: std.ArrayListUnmanaged(macho.data_in_code_entry) = .{},
26+
cies: std.ArrayListUnmanaged(Cie) = .empty,
27+
fdes: std.ArrayListUnmanaged(Fde) = .empty,
28+
eh_frame_data: std.ArrayListUnmanaged(u8) = .empty,
29+
unwind_records: std.ArrayListUnmanaged(UnwindInfo.Record) = .empty,
30+
unwind_records_indexes: std.ArrayListUnmanaged(UnwindInfo.Record.Index) = .empty,
31+
data_in_code: std.ArrayListUnmanaged(macho.data_in_code_entry) = .empty,
3232

3333
alive: bool = true,
3434
hidden: bool = false,
3535

3636
compact_unwind_ctx: CompactUnwindCtx = .{},
37-
output_symtab_ctx: MachO.SymtabCtx = .{},
37+
output_symtab_ctx: MachO.SymtabCtx = .init,
3838

3939
pub fn deinit(self: *Object, allocator: Allocator) void {
4040
allocator.free(self.path);
@@ -1455,7 +1455,7 @@ fn findCompileUnit(self: *Object, gpa: Allocator, dwarf: Dwarf, macho_file: *Mac
14551455
break :str_offsets_base try info_reader.readOffset(cuh.format);
14561456
} else null;
14571457

1458-
var cu: CompileUnit = .{ .comp_dir = .{}, .tu_name = .{} };
1458+
var cu: CompileUnit = .{ .comp_dir = .init, .tu_name = .init };
14591459
for (&[_]struct { Pos, *MachO.String }{
14601460
.{ saved.comp_dir.?, &cu.comp_dir },
14611461
.{ saved.tu_name.?, &cu.tu_name },

src/Symbol.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
value: u64 = 0,
55

66
/// Offset into the linker's intern table.
7-
name: MachO.String = .{},
7+
name: MachO.String = .init,
88

99
/// File where this symbol is defined.
1010
file: File.OptionalIndex = .none,

src/Thunk.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
value: u64 = 0,
22
out_n_sect: u8 = 0,
3-
symbols: std.AutoArrayHashMapUnmanaged(Symbol.UnwrappedRef, void) = .{},
3+
symbols: std.AutoArrayHashMapUnmanaged(Symbol.UnwrappedRef, void) = .empty,
44

55
pub fn deinit(thunk: *Thunk, allocator: Allocator) void {
66
thunk.symbols.deinit(allocator);

src/UnwindInfo.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// List of all unwind records gathered from all objects and sorted
22
/// by allocated relative function address within the section.
3-
records: std.ArrayListUnmanaged(Record.Ref) = .{},
3+
records: std.ArrayListUnmanaged(Record.Ref) = .empty,
44

55
/// List of all personalities referenced by either unwind info entries
66
/// or __eh_frame entries.
@@ -12,11 +12,11 @@ common_encodings: [max_common_encodings]Encoding = undefined,
1212
common_encodings_count: u7 = 0,
1313

1414
/// List of record indexes containing an LSDA pointer.
15-
lsdas: std.ArrayListUnmanaged(u32) = .{},
16-
lsdas_lookup: std.ArrayListUnmanaged(u32) = .{},
15+
lsdas: std.ArrayListUnmanaged(u32) = .empty,
16+
lsdas_lookup: std.ArrayListUnmanaged(u32) = .empty,
1717

1818
/// List of second level pages.
19-
pages: std.ArrayListUnmanaged(Page) = .{},
19+
pages: std.ArrayListUnmanaged(Page) = .empty,
2020

2121
pub fn deinit(info: *UnwindInfo, allocator: Allocator) void {
2222
info.records.deinit(allocator);

0 commit comments

Comments
 (0)