InternPool: remove memoized_decl

This is neither a type nor a value. Simplifies `addStrLit` as well as
the many places that switch on `InternPool.Key`.

This is a partial revert of bec29b9e498e08202679aa29a45dab2a06a69a1e.
This commit is contained in:
Andrew Kelley
2023-05-31 15:00:48 -07:00
parent 870e3843c5
commit bb526426e7
11 changed files with 31 additions and 92 deletions

View File

@@ -88,6 +88,9 @@ embed_table: std.StringHashMapUnmanaged(*EmbedFile) = .{},
/// Stores all Type and Value objects; periodically garbage collected.
intern_pool: InternPool = .{},
/// This is currently only used for string literals.
memoized_decls: std.AutoHashMapUnmanaged(InternPool.Index, Decl.Index) = .{},
/// The set of all the generic function instantiations. This is used so that when a generic
/// function is called twice with the same comptime parameter arguments, both calls dispatch
/// to the same function.
@@ -561,6 +564,7 @@ pub const Decl = struct {
}
mod.destroyFunc(func);
}
_ = mod.memoized_decls.remove(decl.val.ip_index);
if (decl.value_arena) |value_arena| {
value_arena.deinit(gpa);
decl.value_arena = null;
@@ -3285,6 +3289,7 @@ pub fn deinit(mod: *Module) void {
mod.namespaces_free_list.deinit(gpa);
mod.allocated_namespaces.deinit(gpa);
mod.memoized_decls.deinit(gpa);
mod.intern_pool.deinit(gpa);
}