diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-11-01 12:03:26 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-11-24 15:27:03 -0800 |
| commit | d09fd249c090c68f6bba9731572e52f51afa7536 (patch) | |
| tree | b4b7746f2dcb932aaac14b295ec775d984ca13c2 /lib/std/hash.zig | |
| parent | 5ad44c14b0c1f8e55856a8f048a570dad564c231 (diff) | |
| download | zig-d09fd249c090c68f6bba9731572e52f51afa7536.tar.gz zig-d09fd249c090c68f6bba9731572e52f51afa7536.zip | |
std.hash.int: restore previous behavior
In the parent commit, I handled odd bit sizes by upcasting and
truncating. However it seems the else branch is intended to handle
those cases instead, so this commit reverts that behavior.
Diffstat (limited to 'lib/std/hash.zig')
| -rw-r--r-- | lib/std/hash.zig | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/std/hash.zig b/lib/std/hash.zig index b768a85861..7e0afb5d9b 100644 --- a/lib/std/hash.zig +++ b/lib/std/hash.zig @@ -51,12 +51,8 @@ pub fn int(input: anytype) @TypeOf(input) { const Unsigned = @Type(.{ .int = .{ .signedness = .unsigned, .bits = info.bits } }); const casted: Unsigned = @bitCast(input); return @bitCast(int(casted)); - } else if (info.bits < 16) { - return @truncate(int(@as(u16, input))); - } else if (info.bits < 32) { - return @truncate(int(@as(u32, input))); - } else if (info.bits < 64) { - return @truncate(int(@as(u64, input))); + } else if (info.bits < 4) { + return @truncate(int(@as(u4, input))); } var x = input; switch (info.bits) { |
