Skip to content

Commit 1b700c5

Browse files
committed
ZJIT: Don't make unnecessary Cow
1 parent 8c73b10 commit 1b700c5

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

zjit/src/hir.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -734,18 +734,18 @@ impl<'a> std::fmt::Display for InsnPrinter<'a> {
734734
Insn::Defined { op_type, v, .. } => {
735735
// op_type (enum defined_type) printing logic from iseq.c.
736736
// Not sure why rb_iseq_defined_string() isn't exhaustive.
737-
use std::borrow::Cow;
737+
write!(f, "Defined ")?;
738738
let op_type = *op_type as u32;
739-
let op_type = if op_type == DEFINED_FUNC {
740-
Cow::Borrowed("func")
739+
if op_type == DEFINED_FUNC {
740+
write!(f, "func")?;
741741
} else if op_type == DEFINED_REF {
742-
Cow::Borrowed("ref")
742+
write!(f, "ref")?;
743743
} else if op_type == DEFINED_CONST_FROM {
744-
Cow::Borrowed("constant-from")
744+
write!(f, "constant-from")?;
745745
} else {
746-
String::from_utf8_lossy(unsafe { rb_iseq_defined_string(op_type).as_rstring_byte_slice().unwrap() })
746+
write!(f, "{}", String::from_utf8_lossy(unsafe { rb_iseq_defined_string(op_type).as_rstring_byte_slice().unwrap() }))?;
747747
};
748-
write!(f, "Defined {op_type}, {v}")
748+
write!(f, ", {v}")
749749
}
750750
Insn::DefinedIvar { self_val, id, .. } => write!(f, "DefinedIvar {self_val}, :{}", id.contents_lossy().into_owned()),
751751
Insn::GetIvar { self_val, id, .. } => write!(f, "GetIvar {self_val}, :{}", id.contents_lossy().into_owned()),

0 commit comments

Comments
 (0)