Commit 843d5adcd6

Andrew Kelley <andrew@ziglang.org>
2022-04-03 04:10:09
std.ArrayHashMap: lazier verifyContext calls
Companion commit to b45c6c757cb4a16f5021c8bf057d14183036f14c. Related: #11367
1 parent 3b32e0b
Changed files (1)
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,