Skip to content

Commit

Permalink
Cut reason refcell
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdrozd committed Sep 3, 2024
1 parent a7ecb09 commit fd454ec
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/reason.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use core::{cell::RefCell, fmt, iter::once};
use core::{fmt, iter::once};

use std::{
collections::{BTreeMap, HashSet},
Expand Down Expand Up @@ -35,7 +35,7 @@ struct Config {
state: State,
tape: Backstepper,
recs: usize,
prev: Option<Rc<RefCell<Config>>>,
prev: Option<Rc<Config>>,
}

impl Alignment for Config {
Expand Down Expand Up @@ -72,9 +72,7 @@ impl Config {
let mut current = self.prev.clone();

#[expect(clippy::assigning_clones)]
while let Some(prev_rc) = current {
let config = prev_rc.borrow();

while let Some(config) = current {
let pos = config.head();

if pos < leftmost {
Expand Down Expand Up @@ -196,18 +194,18 @@ fn step_configs(configs: ValidatedSteps) -> Option<Configs> {
let mut stepped = Configs::new();

for (instrs, config) in configs {
let config_rc = Rc::new(RefCell::new(config));
let config_rc = Rc::new(config);

for (next_state, next_color, shift) in instrs {
let mut next_tape = config_rc.borrow().tape.clone();
let mut next_tape = config_rc.tape.clone();

next_tape.backstep(shift, next_color);

let mut next_config = Config {
state: next_state,
tape: next_tape,
prev: Some(config_rc.clone()),
recs: config_rc.borrow().recs,
recs: config_rc.recs,
};

if next_config.lin_rec() {
Expand Down

0 comments on commit fd454ec

Please sign in to comment.