aboutsummaryrefslogtreecommitdiffstats
path: root/src/regex/bc.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/regex/bc.rs')
-rw-r--r--src/regex/bc.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/regex/bc.rs b/src/regex/bc.rs
index 5de1513..ea1d086 100644
--- a/src/regex/bc.rs
+++ b/src/regex/bc.rs
@@ -114,8 +114,8 @@ struct Thread<F: Flavor> {
struct VM<'p, F: Flavor> {
instr: &'p [Instr<F>],
- passive_threads: VecDeque<Thread<F>>,
- active_threads: VecDeque<Thread<F>>,
+ passive_threads: Vec<Thread<F>>,
+ active_threads: Vec<Thread<F>>,
hot: BitSet,
warm: BitSet,
}
@@ -124,8 +124,8 @@ impl<'p, F: Flavor> VM<'p, F> {
fn new(instr: &'p [Instr<F>], starting_thread: Thread<F>) -> Self {
Self {
instr,
- passive_threads: vec![starting_thread].into(),
- active_threads: VecDeque::new(),
+ passive_threads: vec![starting_thread],
+ active_threads: Vec::new(),
hot: BitSet::new(instr.len()),
warm: BitSet::new(instr.len()),
}
@@ -142,7 +142,7 @@ impl<'p, F: Flavor> VM<'p, F> {
let bit = t.pc as usize;
if !self.warm.get(bit) {
self.warm.set(bit, true);
- self.active_threads.push_front(t);
+ self.active_threads.push(t);
}
}};
}
@@ -157,13 +157,13 @@ impl<'p, F: Flavor> VM<'p, F> {
}};
}
- while let Some(mut thread) = self.active_threads.pop_front() {
+ while let Some(mut thread) = self.active_threads.pop() {
loop {
match self.instr[thread.pc as usize] {
Instr::Class(_) | Instr::Consume(_) => {
if !self.hot.get(thread.pc as usize) {
self.hot.set(thread.pc as usize, true);
- self.passive_threads.push_back(thread);
+ self.passive_threads.push(thread);
}
}
Instr::Jump(j) => {
@@ -188,6 +188,8 @@ impl<'p, F: Flavor> VM<'p, F> {
break;
}
}
+
+ self.passive_threads.reverse();
}
fn step_consume(&mut self, byte: u8) {