From e22ff3af361be40ccb26992d549d0fdea18b1341 Mon Sep 17 00:00:00 2001 From: Kangzhi Shi Date: Thu, 23 Mar 2023 21:37:28 +0200 Subject: [PATCH] improve Comparable take zelf as reference --- vm/src/types/slot.rs | 49 ++++++++++++-------------------------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/vm/src/types/slot.rs b/vm/src/types/slot.rs index dba2194a69..348c9ca337 100644 --- a/vm/src/types/slot.rs +++ b/vm/src/types/slot.rs @@ -992,58 +992,35 @@ pub trait Comparable: PyPayload { vm: &VirtualMachine, ) -> PyResult; + #[inline] #[pymethod(magic)] - fn eq( - zelf: PyRef, - other: PyObjectRef, - vm: &VirtualMachine, - ) -> PyResult { - Self::cmp(&zelf, &other, PyComparisonOp::Eq, vm) + fn eq(zelf: &Py, other: PyObjectRef, vm: &VirtualMachine) -> PyResult { + Self::cmp(zelf, &other, PyComparisonOp::Eq, vm) } #[inline] #[pymethod(magic)] - fn ne( - zelf: PyRef, - other: PyObjectRef, - vm: &VirtualMachine, - ) -> PyResult { - Self::cmp(&zelf, &other, PyComparisonOp::Ne, vm) + fn ne(zelf: &Py, other: PyObjectRef, vm: &VirtualMachine) -> PyResult { + Self::cmp(zelf, &other, PyComparisonOp::Ne, vm) } #[inline] #[pymethod(magic)] - fn lt( - zelf: PyRef, - other: PyObjectRef, - vm: &VirtualMachine, - ) -> PyResult { - Self::cmp(&zelf, &other, PyComparisonOp::Lt, vm) + fn lt(zelf: &Py, other: PyObjectRef, vm: &VirtualMachine) -> PyResult { + Self::cmp(zelf, &other, PyComparisonOp::Lt, vm) } #[inline] #[pymethod(magic)] - fn le( - zelf: PyRef, - other: PyObjectRef, - vm: &VirtualMachine, - ) -> PyResult { - Self::cmp(&zelf, &other, PyComparisonOp::Le, vm) + fn le(zelf: &Py, other: PyObjectRef, vm: &VirtualMachine) -> PyResult { + Self::cmp(zelf, &other, PyComparisonOp::Le, vm) } #[inline] #[pymethod(magic)] - fn ge( - zelf: PyRef, - other: PyObjectRef, - vm: &VirtualMachine, - ) -> PyResult { - Self::cmp(&zelf, &other, PyComparisonOp::Ge, vm) + fn ge(zelf: &Py, other: PyObjectRef, vm: &VirtualMachine) -> PyResult { + Self::cmp(zelf, &other, PyComparisonOp::Ge, vm) } #[inline] #[pymethod(magic)] - fn gt( - zelf: PyRef, - other: PyObjectRef, - vm: &VirtualMachine, - ) -> PyResult { - Self::cmp(&zelf, &other, PyComparisonOp::Gt, vm) + fn gt(zelf: &Py, other: PyObjectRef, vm: &VirtualMachine) -> PyResult { + Self::cmp(zelf, &other, PyComparisonOp::Gt, vm) } }