micro-optimizing a bit

This commit is contained in:
Devyn Cairns 2024-07-04 04:17:44 -07:00
parent c3712f4337
commit 4ff41e5817

View File

@ -87,14 +87,17 @@ struct EvalContext<'a> {
impl<'a> EvalContext<'a> { impl<'a> EvalContext<'a> {
/// Replace the contents of a register with a new value /// Replace the contents of a register with a new value
fn put_reg(&mut self, reg_id: RegId, new_value: PipelineData) -> PipelineData { #[inline]
log::trace!("{reg_id} = {new_value:?}"); fn put_reg(&mut self, reg_id: RegId, new_value: PipelineData) {
std::mem::replace(&mut self.registers[reg_id.0 as usize], new_value) // log::trace!("{reg_id} <- {new_value:?}");
self.registers[reg_id.0 as usize] = new_value;
} }
/// Replace the contents of a register with `Empty` and then return the value that it contained /// Replace the contents of a register with `Empty` and then return the value that it contained
#[inline]
fn take_reg(&mut self, reg_id: RegId) -> PipelineData { fn take_reg(&mut self, reg_id: RegId) -> PipelineData {
self.put_reg(reg_id, PipelineData::Empty) // log::trace!("<- {reg_id}");
std::mem::replace(&mut self.registers[reg_id.0 as usize], PipelineData::Empty)
} }
/// Take and implicitly collect a register to a value /// Take and implicitly collect a register to a value
@ -113,6 +116,7 @@ impl<'a> EvalContext<'a> {
} }
/// Get the current stack to be used for the callee - either `callee_stack` if set, or `stack` /// Get the current stack to be used for the callee - either `callee_stack` if set, or `stack`
#[inline]
fn callee_stack(&mut self) -> &mut Stack { fn callee_stack(&mut self) -> &mut Stack {
self.callee_stack.as_deref_mut().unwrap_or(self.stack) self.callee_stack.as_deref_mut().unwrap_or(self.stack)
} }