authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-11-01 12:03:26-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-11-24 15:27:03-08:00
logd09fd249c090c68f6bba9731572e52f51afa7536
treeb4b7746f2dcb932aaac14b295ec775d984ca13c2
parent5ad44c14b0c1f8e55856a8f048a570dad564c231

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.

1 files changed, 2 insertions(+), 6 deletions(-)

lib/std/hash.zig+2-6
......@@ -51,12 +51,8 @@ pub fn int(input: anytype) @TypeOf(input) {
5151 const Unsigned = @Type(.{ .int = .{ .signedness = .unsigned, .bits = info.bits } });
5252 const casted: Unsigned = @bitCast(input);
5353 return @bitCast(int(casted));
54 } else if (info.bits < 16) {
55 return @truncate(int(@as(u16, input)));
56 } else if (info.bits < 32) {
57 return @truncate(int(@as(u32, input)));
58 } else if (info.bits < 64) {
59 return @truncate(int(@as(u64, input)));
54 } else if (info.bits < 4) {
55 return @truncate(int(@as(u4, input)));
6056 }
6157 var x = input;
6258 switch (info.bits) {