diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-04-02 19:10:09 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-04-02 19:18:41 -0700 |
| commit | 843d5adcd6ec0b620fe93e0366aa0e8bb92bd171 (patch) | |
| tree | 9fe1bc1f74c64be681f2b140aea477e482289164 /lib/std/array_hash_map.zig | |
| parent | 3b32e0be3187d8815ce20dd6b45665dc4e85b443 (diff) | |
| download | zig-843d5adcd6ec0b620fe93e0366aa0e8bb92bd171.tar.gz zig-843d5adcd6ec0b620fe93e0366aa0e8bb92bd171.zip | |
std.ArrayHashMap: lazier verifyContext calls
Companion commit to b45c6c757cb4a16f5021c8bf057d14183036f14c.
Related: #11367
Diffstat (limited to 'lib/std/array_hash_map.zig')
| -rw-r--r-- | lib/std/array_hash_map.zig | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/std/array_hash_map.zig b/lib/std/array_hash_map.zig index 3ddaac49eb..e582f55819 100644 --- a/lib/std/array_hash_map.zig +++ b/lib/std/array_hash_map.zig @@ -77,12 +77,15 @@ pub fn ArrayHashMap( comptime Context: type, comptime store_hash: bool, ) type { - comptime std.hash_map.verifyContext(Context, K, K, u32, true); return struct { unmanaged: Unmanaged, allocator: Allocator, ctx: Context, + comptime { + std.hash_map.verifyContext(Context, K, K, u32, true); + } + /// The ArrayHashMapUnmanaged type using the same settings as this managed map. pub const Unmanaged = ArrayHashMapUnmanaged(K, V, Context, store_hash); @@ -470,7 +473,6 @@ pub fn ArrayHashMapUnmanaged( comptime Context: type, comptime store_hash: bool, ) type { - comptime std.hash_map.verifyContext(Context, K, K, u32, true); return struct { /// It is permitted to access this field directly. entries: DataList = .{}, @@ -481,6 +483,10 @@ pub fn ArrayHashMapUnmanaged( /// by how many total indexes there are. 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 value is allowed. /// Entry pointers become invalid whenever this ArrayHashMap is modified, |
