| ... | ... | @@ -105,6 +105,7 @@ pub fn findByMnemonic(mnemonic: Mnemonic, args: struct { |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | if (count == 0) return null; |
| 108 | if (count == 1) return candidates[0]; |
| 108 | 109 | |
| 109 | 110 | const EncodingLength = struct { |
| 110 | 111 | fn estimate(encoding: Encoding, params: struct { |
| ... | ... | @@ -112,7 +113,7 @@ pub fn findByMnemonic(mnemonic: Mnemonic, args: struct { |
| 112 | 113 | op2: Instruction.Operand, |
| 113 | 114 | op3: Instruction.Operand, |
| 114 | 115 | op4: Instruction.Operand, |
| 115 | | }) !usize { |
| 116 | }) usize { |
| 116 | 117 | var inst = Instruction{ |
| 117 | 118 | .op1 = params.op1, |
| 118 | 119 | .op2 = params.op2, |
| ... | ... | @@ -122,7 +123,7 @@ pub fn findByMnemonic(mnemonic: Mnemonic, args: struct { |
| 122 | 123 | }; |
| 123 | 124 | var cwriter = std.io.countingWriter(std.io.null_writer); |
| 124 | 125 | inst.encode(cwriter.writer()) catch unreachable; // Not allowed to fail here unless OOM. |
| 125 | | return cwriter.bytes_written; |
| 126 | return @intCast(usize, cwriter.bytes_written); |
| 126 | 127 | } |
| 127 | 128 | }; |
| 128 | 129 | |
| ... | ... | @@ -138,7 +139,7 @@ pub fn findByMnemonic(mnemonic: Mnemonic, args: struct { |
| 138 | 139 | else => {}, |
| 139 | 140 | } |
| 140 | 141 | |
| 141 | | const len = try EncodingLength.estimate(candidate, .{ |
| 142 | const len = EncodingLength.estimate(candidate, .{ |
| 142 | 143 | .op1 = args.op1, |
| 143 | 144 | .op2 = args.op2, |
| 144 | 145 | .op3 = args.op3, |