commit 843d5adcd6ec0b620fe93e0366aa0e8bb92bd171 (tree)
parent 3b32e0be3187d8815ce20dd6b45665dc4e85b443
Author: Andrew Kelley <andrew@ziglang.org>
Date: Sat, 2 Apr 2022 19:10:09 -0700
std.ArrayHashMap: lazier verifyContext calls
Companion commit to b45c6c757cb4a16f5021c8bf057d14183036f14c.
Related: #11367
Diffstat:
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git 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,