Skip to content

Commit 8685c4f

Browse files
committed
no rc operation for nth_value
1 parent 503a147 commit 8685c4f

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

vm/src/frame.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::{
44
asyncgenerator::PyAsyncGenWrappedValue,
55
function::{PyCell, PyCellRef, PyFunction},
66
tuple::{PyTuple, PyTupleTyped},
7-
PyBaseExceptionRef, PyCode, PyCoroutine, PyDict, PyDictRef, PyGenerator, PyListRef, PySet,
7+
PyBaseExceptionRef, PyCode, PyCoroutine, PyDict, PyDictRef, PyGenerator, PyList, PySet,
88
PySlice, PyStr, PyStrRef, PyTraceback, PyTypeRef,
99
},
1010
bytecode,
@@ -670,19 +670,19 @@ impl ExecutingFrame<'_> {
670670
bytecode::Instruction::ListAppend { i } => {
671671
let item = self.pop_value();
672672
let obj = self.nth_value(*i);
673-
let list: PyListRef = unsafe {
673+
let list: &Py<PyList> = unsafe {
674674
// SAFETY: trust compiler
675-
obj.downcast_unchecked()
675+
obj.downcast_unchecked_ref()
676676
};
677677
list.append(item);
678678
Ok(None)
679679
}
680680
bytecode::Instruction::SetAdd { i } => {
681681
let item = self.pop_value();
682682
let obj = self.nth_value(*i);
683-
let set: PyRef<PySet> = unsafe {
683+
let set: &Py<PySet> = unsafe {
684684
// SAFETY: trust compiler
685-
obj.downcast_unchecked()
685+
obj.downcast_unchecked_ref()
686686
};
687687
set.add(item, vm)?;
688688
Ok(None)
@@ -691,9 +691,9 @@ impl ExecutingFrame<'_> {
691691
let key = self.pop_value();
692692
let value = self.pop_value();
693693
let obj = self.nth_value(*i);
694-
let dict: PyDictRef = unsafe {
694+
let dict: &Py<PyDict> = unsafe {
695695
// SAFETY: trust compiler
696-
obj.downcast_unchecked()
696+
obj.downcast_unchecked_ref()
697697
};
698698
dict.set_item(&*key, value, vm)?;
699699
Ok(None)
@@ -703,9 +703,9 @@ impl ExecutingFrame<'_> {
703703
let value = self.pop_value();
704704
let key = self.pop_value();
705705
let obj = self.nth_value(*i);
706-
let dict: PyDictRef = unsafe {
706+
let dict: &Py<PyDict> = unsafe {
707707
// SAFETY: trust compiler
708-
obj.downcast_unchecked()
708+
obj.downcast_unchecked_ref()
709709
};
710710
dict.set_item(&*key, value, vm)?;
711711
Ok(None)
@@ -1811,8 +1811,9 @@ impl ExecutingFrame<'_> {
18111811
}
18121812

18131813
#[inline]
1814-
fn nth_value(&self, depth: u32) -> PyObjectRef {
1815-
self.state.stack[self.state.stack.len() - depth as usize - 1].clone()
1814+
fn nth_value(&self, depth: u32) -> &PyObject {
1815+
let stack = &self.state.stack;
1816+
&stack[stack.len() - depth as usize - 1]
18161817
}
18171818

18181819
#[cold]

0 commit comments

Comments
 (0)