8000 refactor: remove dyn dispatch in trace.rs · RustPython/RustPython@ca1720d · GitHub
[go: up one dir, main page]

Skip to content

Commit ca1720d

Browse files
committed
refactor: remove dyn dispatch in trace.rs
1 parent 61c6f7b commit ca1720d

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

vm/src/object/gc/trace.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ pub enum GcStatus {
1717
ShouldKeep,
1818
}
1919

20-
#[enum_dispatch]
2120
pub trait GcObjPtr: GcTrace {
2221
fn inc(&self);
2322
fn dec(&self) -> GcStatus;
@@ -28,20 +27,6 @@ pub trait GcObjPtr: GcTrace {
2827
fn as_ptr(&self) -> NonNull<dyn GcObjPtr>;
2928
}
3029

31-
#[enum_dispatch(GcObjPtr)]
32-
pub(in crate::object) enum GcObj {
33-
PyInner(PyInner<Erased>),
34-
PyObject(PyObject),
35-
}
36-
37-
unsafe impl GcTrace for GcObj {
38-
fn trace(&self, tracer_fn: &mut TracerFn) {
39-
match self {
40-
GcObj::PyInner(v) => v.trace(tracer_fn),
41-
GcObj::PyObject(v) => v.trace(tracer_fn),
42-
}
43-
}
44-
}
4530
/// use `trace()` to call on all owned ObjectRef
4631
///
4732
/// # Safety
@@ -67,7 +52,7 @@ pub unsafe trait GcTrace {
6752

6853
/// A `TracerFn` is a callback function that is invoked for each `PyGcObjectRef` owned
6954
/// by an instance of something.
70-
pub type TracerFn<'a> = dyn FnMut(&dyn GcObjPtr) + 'a;
55+
pub type TracerFn<'a> = dyn FnMut(&PyObject) + 'a;
7156

7257
unsafe impl GcTrace for PyObjectRef {
7358
#[inline]

0 commit comments

Comments
 (0)
0