From 69f91170f6a216afa438bc292460295d2af0cae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Autin?= Date: Wed, 5 Apr 2023 13:34:06 +0200 Subject: [PATCH] Optimized to avoid cloning heap values --- src/kernel/exception.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/kernel/exception.rs b/src/kernel/exception.rs index 0cf5921..de4defe 100644 --- a/src/kernel/exception.rs +++ b/src/kernel/exception.rs @@ -65,16 +65,12 @@ fn syscall(machine: &mut Machine, system: &mut System) -> Result Ok(MachineOk::Shutdown), SC_EXIT => { - match &system.get_thread_manager().g_current_thread { - Some(th) => { - let th = Rc::clone(th); - system.get_thread_manager().thread_finish(machine, th); - Ok(MachineOk::Ok) - }, - None => { - Err("Current thread is None".into()) - } - } + let th = match &system.get_thread_manager().g_current_thread { + Some(th) => th, + None => Err("Current thread is None".into()) + }?; + system.get_thread_manager().thread_finish(machine, th); + Ok(MachineOk::Ok) }, SC_EXEC => todo!(), SC_JOIN => todo!(),