diff options
Diffstat (limited to 'src/Package.zig')
| -rw-r--r-- | src/Package.zig | 29 |
1 files changed, 1 insertions, 28 deletions
diff --git a/src/Package.zig b/src/Package.zig index d5960dcf9a..33ff4766ca 100644 --- a/src/Package.zig +++ b/src/Package.zig @@ -15,9 +15,6 @@ root_src_path: []const u8, table: Table = .{}, parent: ?*Package = null, -// Used when freeing packages -seen: bool = false, - /// Allocate a Package. No references to the slices passed are kept. pub fn create( gpa: *Allocator, @@ -58,20 +55,10 @@ pub fn destroy(pkg: *Package, gpa: *Allocator) void { pkg.root_src_directory.handle.close(); } - // First we recurse into all the packages and remove packages from the tables - // once we have seen it before. We do this to make sure that that - // a package can only be found once in the whole tree. - if (!pkg.seen) { - pkg.seen = true; - pkg.markSeen(gpa); - } - { var it = pkg.table.iterator(); while (it.next()) |kv| { - if (pkg != kv.value) { - kv.value.destroy(gpa); - } + kv.value.destroy(gpa); gpa.free(kv.key); } } @@ -80,20 +67,6 @@ pub fn destroy(pkg: *Package, gpa: *Allocator) void { gpa.destroy(pkg); } -fn markSeen(pkg: *Package, gpa: *Allocator) void { - var it = pkg.table.iterator(); - while (it.next()) |kv| { - if (pkg != kv.value) { - if (kv.value.seen) { - pkg.table.removeAssertDiscard(kv.key); - } else { - kv.value.seen = true; - kv.value.markSeen(gpa); - } - } - } -} - pub fn add(pkg: *Package, gpa: *Allocator, name: []const u8, package: *Package) !void { try pkg.table.ensureCapacity(gpa, pkg.table.count() + 1); const name_dupe = try mem.dupe(gpa, u8, name); |
