Skip to content

Commit e153101

Browse files
committed
Inline LVar::get/set/set_from
1 parent 6100d4f commit e153101

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/logic/vm/variables.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::{
2-
borrow::Cow,
32
fmt::Display,
43
hash::{Hash, Hasher},
54
num::TryFromIntError,
@@ -157,6 +156,7 @@ impl LVar {
157156
}
158157
}
159158

159+
#[inline(always)]
160160
pub fn get<'a>(&'a self, state: &'a ProcessorState) -> LValue {
161161
match self {
162162
Self::Variable(i) => state.variables[*i].clone(),
@@ -170,16 +170,8 @@ impl LVar {
170170
}
171171
}
172172

173-
/// Returns `None` if this is a variable for which `self.set` would be a no-op.
174-
pub fn try_get_writable<'a>(&'a self, state: &'a ProcessorState) -> Option<Cow<'a, LValue>> {
175-
match self {
176-
Self::Variable(i) => Some(Cow::Borrowed(&state.variables[*i])),
177-
Self::Counter => Some(Cow::Owned(state.counter.into())),
178-
_ => None,
179-
}
180-
}
181-
182173
/// Returns true if the variable was successfully set.
174+
#[inline(always)]
183175
pub fn set(&self, state: &mut ProcessorState, value: LValue) -> bool {
184176
match self {
185177
Self::Variable(i) => {
@@ -191,6 +183,7 @@ impl LVar {
191183
}
192184
}
193185

186+
#[inline(always)]
194187
pub fn set_from(&self, state: &mut ProcessorState, other: &LVar) {
195188
self.set(state, other.get(state));
196189
}

0 commit comments

Comments
 (0)