diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-12-18 01:57:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-18 01:57:49 +0200 |
| commit | 901c3e96368bd9fa9ee9858c0295ee05ef1d7146 (patch) | |
| tree | b5a12345800be59ca68070ce1eff68479c98fff8 /src/value.zig | |
| parent | 9cc49548aa3f98b40a3d7a9cbc12d55ae7a9a298 (diff) | |
| parent | 35750cd54f41477f25c77b8c44a220b57b40fd60 (diff) | |
| download | zig-901c3e96368bd9fa9ee9858c0295ee05ef1d7146.tar.gz zig-901c3e96368bd9fa9ee9858c0295ee05ef1d7146.zip | |
Merge pull request #13552 from hryx/comparus-tautologicus
Sema: elide integer comparisons with guaranteed outcomes
Diffstat (limited to 'src/value.zig')
| -rw-r--r-- | src/value.zig | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/value.zig b/src/value.zig index 3d5636ee34..b0558487f9 100644 --- a/src/value.zig +++ b/src/value.zig @@ -1756,17 +1756,8 @@ pub const Value = extern union { const info = ty.intInfo(target); var buffer: Value.BigIntSpace = undefined; - const operand_bigint = val.toBigInt(&buffer, target); - - var limbs_buffer: [4]std.math.big.Limb = undefined; - var result_bigint = BigIntMutable{ - .limbs = &limbs_buffer, - .positive = undefined, - .len = undefined, - }; - result_bigint.popCount(operand_bigint, info.bits); - - return result_bigint.toConst().to(u64) catch unreachable; + const int = val.toBigInt(&buffer, target); + return @intCast(u64, int.popCount(info.bits)); }, } } |
