From 7ad76740d4e78097da35c1b8251c588bda723f48 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 15 Jan 2025 03:26:43 -0800 Subject: [PATCH] common: tidy instruction module --- lib/common/src/instruction.rs | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/common/src/instruction.rs b/lib/common/src/instruction.rs index 3b71db9..867ab7f 100644 --- a/lib/common/src/instruction.rs +++ b/lib/common/src/instruction.rs @@ -6,6 +6,7 @@ pub struct TimedInstruction{ pub instruction:I, } impl TimedInstruction{ + #[inline] pub fn set_time(self,new_time:Time)->TimedInstruction{ TimedInstruction{ time:new_time, @@ -29,6 +30,7 @@ pub trait InstructionFeedback:InstructionEmitter+Instruction where Time:Copy, { + #[inline] fn process_exhaustive(&mut self,time_limit:Time){ while let Some(instruction)=self.next_instruction(time_limit){ self.process_instruction(instruction); @@ -49,6 +51,7 @@ pub struct InstructionCollector{ impl InstructionCollector where Time:Copy+PartialOrd, { + #[inline] pub const fn new(time:Time)->Self{ Self{ time, @@ -60,24 +63,18 @@ impl InstructionCollector self.time } pub fn collect(&mut self,instruction:Option>){ - match instruction{ - Some(unwrap_instruction)=>{ - if unwrap_instruction.time(), + if let Some(ins)=instruction{ + if ins.timeOption>{ //STEAL INSTRUCTION AND DESTROY INSTRUCTIONCOLLECTOR - match self.instruction{ - Some(instruction)=>Some(TimedInstruction{ - time:self.time, - instruction - }), - None=>None, - } + self.instruction.map(|instruction|TimedInstruction{ + time:self.time, + instruction + }) } }