MCPcopy Index your code
hub / github.com/RustPython/RustPython / specialize_contains_op

Method specialize_contains_op

crates/vm/src/frame.rs:9068–9087  ·  view source on GitHub ↗
(&mut self, vm: &VirtualMachine, instr_idx: usize, cache_base: usize)

Source from the content-addressed store, hash-verified

9066 }
9067
9068 fn specialize_contains_op(&mut self, vm: &VirtualMachine, instr_idx: usize, cache_base: usize) {
9069 if !matches!(
9070 self.code.instructions.read_op(instr_idx),
9071 Instruction::ContainsOp { .. }
9072 ) {
9073 return;
9074 }
9075 let haystack = self.top_value(); // b = TOS = haystack
9076 let new_op = if haystack.downcast_ref_if_exact::<PyDict>(vm).is_some() {
9077 Some(Instruction::ContainsOpDict)
9078 } else if haystack.downcast_ref_if_exact::<PySet>(vm).is_some()
9079 || haystack.downcast_ref_if_exact::<PyFrozenSet>(vm).is_some()
9080 {
9081 Some(Instruction::ContainsOpSet)
9082 } else {
9083 None
9084 };
9085
9086 self.commit_specialization(instr_idx, cache_base, new_op);
9087 }
9088
9089 fn specialize_unpack_sequence(
9090 &mut self,

Callers 1

execute_instructionMethod · 0.80

Calls 3

top_valueMethod · 0.80
commit_specializationMethod · 0.80
SomeClass · 0.50

Tested by

no test coverage detected