diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-08-04 23:51:45 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-08-05 09:56:02 -0700 |
| commit | 196e36bbb27b0f0ebd7cd7a866b85f477b3662fb (patch) | |
| tree | 04efce99fc296278385acbd0a27acdb52d916358 /src/Zcu.zig | |
| parent | c47ec4f3d7a6bf79be3adcffa33aa51bcc26ed0b (diff) | |
| download | zig-196e36bbb27b0f0ebd7cd7a866b85f477b3662fb.tar.gz zig-196e36bbb27b0f0ebd7cd7a866b85f477b3662fb.zip | |
std: remove BoundedArray
This use case is handled by ArrayListUnmanaged via the "...Bounded"
method variants, and it's more optimal to share machine code, versus
generating multiple versions of each function for differing array
lengths.
Diffstat (limited to 'src/Zcu.zig')
| -rw-r--r-- | src/Zcu.zig | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Zcu.zig b/src/Zcu.zig index c444d57bf6..d77a6edc31 100644 --- a/src/Zcu.zig +++ b/src/Zcu.zig @@ -268,7 +268,8 @@ nav_val_analysis_queued: std.AutoArrayHashMapUnmanaged(InternPool.Nav.Index, voi /// These are the modules which we initially queue for analysis in `Compilation.update`. /// `resolveReferences` will use these as the root of its reachability traversal. -analysis_roots: std.BoundedArray(*Package.Module, 4) = .{}, +analysis_roots_buffer: [4]*Package.Module, +analysis_roots_len: usize = 0, /// This is the cached result of `Zcu.resolveReferences`. It is computed on-demand, and /// reset to `null` when any semantic analysis occurs (since this invalidates the data). /// Allocated into `gpa`. @@ -4013,8 +4014,8 @@ fn resolveReferencesInner(zcu: *Zcu) !std.AutoHashMapUnmanaged(AnalUnit, ?Resolv // This is not a sufficient size, but a lower bound. try result.ensureTotalCapacity(gpa, @intCast(zcu.reference_table.count())); - try type_queue.ensureTotalCapacity(gpa, zcu.analysis_roots.len); - for (zcu.analysis_roots.slice()) |mod| { + try type_queue.ensureTotalCapacity(gpa, zcu.analysis_roots_len); + for (zcu.analysisRoots()) |mod| { const file = zcu.module_roots.get(mod).?.unwrap() orelse continue; const root_ty = zcu.fileRootType(file); if (root_ty == .none) continue; @@ -4202,6 +4203,10 @@ fn resolveReferencesInner(zcu: *Zcu) !std.AutoHashMapUnmanaged(AnalUnit, ?Resolv return result; } +pub fn analysisRoots(zcu: *Zcu) []*Package.Module { + return zcu.analysis_roots_buffer[0..zcu.analysis_roots_len]; +} + pub fn fileByIndex(zcu: *const Zcu, file_index: File.Index) *File { return zcu.intern_pool.filePtr(file_index); } |
