| ... | @@ -787,12 +787,12 @@ pub fn readFromPackedMemory( | ... | @@ -787,12 +787,12 @@ pub fn readFromPackedMemory( |
| 787 | if (bits == 0) return mod.intValue(ty, 0); | 787 | if (bits == 0) return mod.intValue(ty, 0); |
| 788 | | 788 | |
| 789 | // Fast path for integers <= u64 | 789 | // Fast path for integers <= u64 |
| 790 | if (bits <= 64) { | 790 | if (bits <= 64) switch (int_info.signedness) { |
| 791 | return mod.intValue( | 791 | // Use different backing types for unsigned vs signed to avoid the need to go via |
| 792 | ty, | 792 | // a larger type like `i128`. |
| 793 | std.mem.readVarPackedInt(i64, buffer, bit_offset, bits, endian, int_info.signedness), | 793 | .unsigned => return mod.intValue(ty, std.mem.readVarPackedInt(u64, buffer, bit_offset, bits, endian, .unsigned)), |
| 794 | ); | 794 | .signed => return mod.intValue(ty, std.mem.readVarPackedInt(i64, buffer, bit_offset, bits, endian, .signed)), |
| 795 | } | 795 | }; |
| 796 | | 796 | |
| 797 | // Slow path, we have to construct a big-int | 797 | // Slow path, we have to construct a big-int |
| 798 | const abi_size = @as(usize, @intCast(ty.abiSize(mod))); | 798 | const abi_size = @as(usize, @intCast(ty.abiSize(mod))); |