analyze: deinit AST once search in a file is done

arena allocator would take care of it upon program exit but deinit'ing earlier
may make a mem footprint difference when searching an arbitrary large
number of files.
0.10
alex 2 years ago
parent 6c8e03ebd8
commit ba68c4a971

@ -7,7 +7,8 @@ const Ast = std.zig.Ast;
///
/// results are printed using ais.
pub fn search(alloc: std.mem.Allocator, ais: *output.Ais, source: [:0]const u8, query: ?[]const u8) !void {
const tree = try std.zig.parse(alloc, source);
var tree = try std.zig.parse(alloc, source);
defer tree.deinit(alloc);
for (tree.rootDecls()) |decl| {
if (!isPublic(tree, decl)) {
continue;

Loading…
Cancel
Save