Skip to content

Commit

Permalink
call current_cfg only once
Browse files Browse the repository at this point in the history
  • Loading branch information
sakateka committed Mar 27, 2018
1 parent e213343 commit 47dbbc5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,10 @@ impl DPDA {
}

pub fn accepting(&self) -> bool {
let accept = self.accept_states.contains(&self.current_cfg().state);
let cfg = self.current_cfg();
let accept = self.accept_states.contains(&cfg.state);
if self.accept_by_empty_stack {
accept && self.current_cfg().stack.is_empty()
accept && cfg.stack.is_empty()
} else {
accept
}
Expand Down

0 comments on commit 47dbbc5

Please sign in to comment.