From 8fd984a7672bd0876079b86ace35cb2b3bdcfc32 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Sun, 19 Mar 2023 01:51:45 +0900 Subject: [PATCH] clean up coroutine --- vm/src/builtins/coroutine.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/vm/src/builtins/coroutine.rs b/vm/src/builtins/coroutine.rs index 7c400274e..76d15b3ae 100644 --- a/vm/src/builtins/coroutine.rs +++ b/vm/src/builtins/coroutine.rs @@ -45,13 +45,13 @@ impl PyCoroutine { } #[pymethod] - fn send(zelf: PyRef, value: PyObjectRef, vm: &VirtualMachine) -> PyResult { + fn send(zelf: &Py, value: PyObjectRef, vm: &VirtualMachine) -> PyResult { zelf.inner.send(zelf.as_object(), value, vm) } #[pymethod] fn throw( - zelf: PyRef, + zelf: &Py, exc_type: PyObjectRef, exc_val: OptionalArg, exc_tb: OptionalArg, @@ -67,7 +67,7 @@ impl PyCoroutine { } #[pymethod] - fn close(zelf: PyRef, vm: &VirtualMachine) -> PyResult<()> { + fn close(zelf: &Py, vm: &VirtualMachine) -> PyResult<()> { zelf.inner.close(zelf.as_object(), vm) } @@ -111,7 +111,7 @@ impl Representable for PyCoroutine { impl IterNextIterable for PyCoroutine {} impl IterNext for PyCoroutine { fn next(zelf: &Py, vm: &VirtualMachine) -> PyResult { - Self::send(zelf.to_owned(), vm.ctx.none(), vm) + Self::send(zelf, vm.ctx.none(), vm) } } @@ -131,8 +131,8 @@ impl PyPayload for PyCoroutineWrapper { #[pyclass(with(IterNext))] impl PyCoroutineWrapper { #[pymethod] - fn send(zelf: PyRef, val: PyObjectRef, vm: &VirtualMachine) -> PyResult { - PyCoroutine::send(zelf.coro.clone(), val, vm) + fn send(&self, val: PyObjectRef, vm: &VirtualMachine) -> PyResult { + PyCoroutine::send(&self.coro, val, vm) } #[pymethod] @@ -143,14 +143,14 @@ impl PyCoroutineWrapper { exc_tb: OptionalArg, vm: &VirtualMachine, ) -> PyResult { - PyCoroutine::throw(self.coro.clone(), exc_type, exc_val, exc_tb, vm) + PyCoroutine::throw(&self.coro, exc_type, exc_val, exc_tb, vm) } } impl IterNextIterable for PyCoroutineWrapper {} impl IterNext for PyCoroutineWrapper { fn next(zelf: &Py, vm: &VirtualMachine) -> PyResult { - Self::send(zelf.to_owned(), vm.ctx.none(), vm) + Self::send(zelf, vm.ctx.none(), vm) } }