From 7f2466e65fe0b7411792ce3d3f186893ed22379d Mon Sep 17 00:00:00 2001 From: mlugg Date: Sat, 17 Aug 2024 11:40:25 +0100 Subject: [PATCH] std.BoundedArray: add clear() --- lib/std/bounded_array.zig | 5 +++++ src/Compilation.zig | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/std/bounded_array.zig b/lib/std/bounded_array.zig index 59f68e8cf8..85a175003d 100644 --- a/lib/std/bounded_array.zig +++ b/lib/std/bounded_array.zig @@ -72,6 +72,11 @@ pub fn BoundedArrayAligned( self.len = @intCast(len); } + /// Remove all elements from the slice. + pub fn clear(self: *Self) void { + self.len = 0; + } + /// Copy the content of an existing slice. pub fn fromSlice(m: []const T) error{Overflow}!Self { var list = try init(m.len); diff --git a/src/Compilation.zig b/src/Compilation.zig index 05a9661101..86f5a6e4c4 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -2264,7 +2264,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void { } } - zcu.analysis_roots.resize(0) catch unreachable; + zcu.analysis_roots.clear(); try comp.queueJob(.{ .analyze_mod = std_mod }); zcu.analysis_roots.appendAssumeCapacity(std_mod);