Remove some uses of foo.expect(&format!(...)) pattern
This eagerly evaluates the `format!` and produces a `String` with a heap allocation, regardless whether `foo` is `Some`/`Ok` or `None`/`Err`. Using `foo.unwrap_or_else(|| panic!(...))` makes it so that the error message formatting is only evaluated if `foo` is `None`/`Err`.
This commit is contained in:
@@ -349,7 +349,7 @@ impl ABIMachineSpec for X64ABIMachineSpec {
|
||||
to_bits: u8,
|
||||
) -> Self::I {
|
||||
let ext_mode = ExtMode::new(from_bits as u16, to_bits as u16)
|
||||
.expect(&format!("invalid extension: {} -> {}", from_bits, to_bits));
|
||||
.unwrap_or_else(|| panic!("invalid extension: {} -> {}", from_bits, to_bits));
|
||||
if is_signed {
|
||||
Inst::movsx_rm_r(ext_mode, RegMem::reg(from_reg), to_reg)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user