std.ArrayHashMap: lazier verifyContext calls

Companion commit to b45c6c757cb4a16f5021c8bf057d14183036f14c.

Related: #11367
This commit is contained in:
Andrew Kelley 2022-04-02 19:10:09 -07:00
parent 3b32e0be31
commit 843d5adcd6

View File

@ -77,12 +77,15 @@ pub fn ArrayHashMap(
comptime Context: type, comptime Context: type,
comptime store_hash: bool, comptime store_hash: bool,
) type { ) type {
comptime std.hash_map.verifyContext(Context, K, K, u32, true);
return struct { return struct {
unmanaged: Unmanaged, unmanaged: Unmanaged,
allocator: Allocator, allocator: Allocator,
ctx: Context, ctx: Context,
comptime {
std.hash_map.verifyContext(Context, K, K, u32, true);
}
/// The ArrayHashMapUnmanaged type using the same settings as this managed map. /// The ArrayHashMapUnmanaged type using the same settings as this managed map.
pub const Unmanaged = ArrayHashMapUnmanaged(K, V, Context, store_hash); pub const Unmanaged = ArrayHashMapUnmanaged(K, V, Context, store_hash);
@ -470,7 +473,6 @@ pub fn ArrayHashMapUnmanaged(
comptime Context: type, comptime Context: type,
comptime store_hash: bool, comptime store_hash: bool,
) type { ) type {
comptime std.hash_map.verifyContext(Context, K, K, u32, true);
return struct { return struct {
/// It is permitted to access this field directly. /// It is permitted to access this field directly.
entries: DataList = .{}, entries: DataList = .{},
@ -481,6 +483,10 @@ pub fn ArrayHashMapUnmanaged(
/// by how many total indexes there are. /// by how many total indexes there are.
index_header: ?*IndexHeader = null, index_header: ?*IndexHeader = null,
comptime {
std.hash_map.verifyContext(Context, K, K, u32, true);
}
/// Modifying the key is allowed only if it does not change the hash. /// Modifying the key is allowed only if it does not change the hash.
/// Modifying the value is allowed. /// Modifying the value is allowed.
/// Entry pointers become invalid whenever this ArrayHashMap is modified, /// Entry pointers become invalid whenever this ArrayHashMap is modified,