From 47e5a563337d71cfc95838aacc3ede0db5a3a999 Mon Sep 17 00:00:00 2001 From: Ratan Kaliani Date: Wed, 7 Aug 2024 00:29:23 -0700 Subject: [PATCH] fix parse cycle tracker --- core/src/syscall/write.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/core/src/syscall/write.rs b/core/src/syscall/write.rs index f910e5bd2d..9c42252b93 100644 --- a/core/src/syscall/write.rs +++ b/core/src/syscall/write.rs @@ -90,17 +90,16 @@ enum CycleTrackerCommand { /// Parse a cycle tracker command from a string. If the string does not match any known command, returns None. fn parse_cycle_tracker_command(s: &str) -> Option { - if let Some((command, fn_name)) = s.split_once(':') { - let trimmed_name = fn_name.trim().to_string(); - match command { - "cycle-tracker-start" => Some(CycleTrackerCommand::Start(trimmed_name)), - "cycle-tracker-end" => Some(CycleTrackerCommand::End(trimmed_name)), - "cycle-tracker-report-start" => Some(CycleTrackerCommand::ReportStart(trimmed_name)), - "cycle-tracker-report-end" => Some(CycleTrackerCommand::ReportEnd(trimmed_name)), - _ => None, - }; + let (command, fn_name) = s.split_once(':')?; + let trimmed_name = fn_name.trim().to_string(); + + match command { + "cycle-tracker-start" => Some(CycleTrackerCommand::Start(trimmed_name)), + "cycle-tracker-end" => Some(CycleTrackerCommand::End(trimmed_name)), + "cycle-tracker-report-start" => Some(CycleTrackerCommand::ReportStart(trimmed_name)), + "cycle-tracker-report-end" => Some(CycleTrackerCommand::ReportEnd(trimmed_name)), + _ => None, } - None } /// Handle a cycle tracker command.