diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-07-12 18:21:19 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-12 18:21:19 -0400 |
| commit | 9b79ce1cd302a196bbb49e5fa89657bd840f4066 (patch) | |
| tree | f717633b02bdd9cf1c7bc724908e8d19ef097981 /src/type.zig | |
| parent | 3063f0a5ed373947badd0af056db310283c76e37 (diff) | |
| parent | 28dd9d478d24190ab5c8c4b892d7dfc16c380ae0 (diff) | |
| download | zig-9b79ce1cd302a196bbb49e5fa89657bd840f4066.tar.gz zig-9b79ce1cd302a196bbb49e5fa89657bd840f4066.zip | |
Merge pull request #9365 from ifreund/hash-map-fix
std/hash_map: fix ensureUnusedCapacity() over-allocating
Diffstat (limited to 'src/type.zig')
| -rw-r--r-- | src/type.zig | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/type.zig b/src/type.zig index 8ded2ee906..52a82c0b93 100644 --- a/src/type.zig +++ b/src/type.zig @@ -602,7 +602,7 @@ pub const Type = extern union { return hasher.final(); } - pub const HashContext = struct { + pub const HashContext64 = struct { pub fn hash(self: @This(), t: Type) u64 { _ = self; return t.hash(); @@ -613,6 +613,17 @@ pub const Type = extern union { } }; + pub const HashContext32 = struct { + pub fn hash(self: @This(), t: Type) u32 { + _ = self; + return @truncate(u32, t.hash()); + } + pub fn eql(self: @This(), a: Type, b: Type) bool { + _ = self; + return a.eql(b); + } + }; + pub fn copy(self: Type, allocator: *Allocator) error{OutOfMemory}!Type { if (self.tag_if_small_enough < Tag.no_payload_count) { return Type{ .tag_if_small_enough = self.tag_if_small_enough }; |
