ZJIT: Take a slice instead of Vec in test code

Shorter code and more efficient.
This commit is contained in:
Alan Wu 2025-06-05 22:02:52 +09:00
parent 2b810ac595
commit cd7c5a3484
Notes: git 2025-06-06 13:30:32 +00:00

View File

@ -2736,9 +2736,9 @@ mod tests {
} }
#[track_caller] #[track_caller]
fn assert_method_hir_with_opcodes(method: &str, opcodes: Vec<u32>, hir: Expect) { fn assert_method_hir_with_opcodes(method: &str, opcodes: &[u32], hir: Expect) {
let iseq = crate::cruby::with_rubyvm(|| get_method_iseq(method)); let iseq = crate::cruby::with_rubyvm(|| get_method_iseq(method));
for opcode in opcodes { for &opcode in opcodes {
assert!(iseq_contains_opcode(iseq, opcode), "iseq {method} does not contain {}", insn_name(opcode as usize)); assert!(iseq_contains_opcode(iseq, opcode), "iseq {method} does not contain {}", insn_name(opcode as usize));
} }
unsafe { crate::cruby::rb_zjit_profile_disable(iseq) }; unsafe { crate::cruby::rb_zjit_profile_disable(iseq) };
@ -2748,7 +2748,7 @@ mod tests {
#[track_caller] #[track_caller]
fn assert_method_hir_with_opcode(method: &str, opcode: u32, hir: Expect) { fn assert_method_hir_with_opcode(method: &str, opcode: u32, hir: Expect) {
assert_method_hir_with_opcodes(method, vec![opcode], hir) assert_method_hir_with_opcodes(method, &[opcode], hir)
} }
#[track_caller] #[track_caller]
@ -2982,7 +2982,7 @@ mod tests {
a a
end end
"); ");
assert_method_hir_with_opcodes("test", vec![YARVINSN_getlocal_WC_0, YARVINSN_setlocal_WC_0], expect![[r#" assert_method_hir_with_opcodes("test", &[YARVINSN_getlocal_WC_0, YARVINSN_setlocal_WC_0], expect![[r#"
fn test: fn test:
bb0(v0:BasicObject): bb0(v0:BasicObject):
v1:NilClassExact = Const Value(nil) v1:NilClassExact = Const Value(nil)