Skip to content

Commit

Permalink
fix parse cycle tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani committed Aug 7, 2024
1 parent 955b475 commit 47e5a56
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions core/src/syscall/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CycleTrackerCommand> {
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.
Expand Down

0 comments on commit 47e5a56

Please sign in to comment.