Skip to content

Commit

Permalink
Small refactor to use an usize over an AtomicUsize
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Sep 1, 2022
1 parent 31dc6d7 commit 7ff7b91
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions minijinja/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::value::{self, Object, RcType, Value, ValueIterator, ValueRepr};
use crate::AutoEscape;

pub struct LoopState {
len: AtomicUsize,
len: usize,
idx: AtomicUsize,
depth: usize,
}
Expand Down Expand Up @@ -45,7 +45,7 @@ impl Object for LoopState {

fn get_attr(&self, name: &str) -> Option<Value> {
let idx = self.idx.load(Ordering::Relaxed) as u64;
let len = self.len.load(Ordering::Relaxed) as u64;
let len = self.len as u64;
match name {
"index0" => Some(Value::from(idx)),
"index" => Some(Value::from(idx + 1)),
Expand Down Expand Up @@ -89,7 +89,7 @@ impl fmt::Display for LoopState {
f,
"<loop {}/{}>",
self.idx.load(Ordering::Relaxed),
self.len.load(Ordering::Relaxed)
self.len
)
}
}
Expand Down Expand Up @@ -765,7 +765,7 @@ impl<'env> Vm<'env> {
current_recursion_jump: next_loop_recursion_jump.take(),
controller: RcType::new(LoopState {
idx: AtomicUsize::new(!0usize),
len: AtomicUsize::new(len),
len,
depth,
}),
}),
Expand Down

0 comments on commit 7ff7b91

Please sign in to comment.