From bd3818f93244f09dfcef768c63515c84b784b416 Mon Sep 17 00:00:00 2001 From: Tim Beurskens Date: Wed, 23 Mar 2022 14:47:12 +0100 Subject: [PATCH 1/3] remove redundant hash computation in mk_choice --- src/bdd.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/bdd.rs b/src/bdd.rs index 97563ba..72e4d0c 100644 --- a/src/bdd.rs +++ b/src/bdd.rs @@ -182,13 +182,15 @@ impl BDDEnv { // early simplification step let ins = self.simplify(&Rc::new(BDD::Choice(true_subtree, symbol, false_subtree))); - if self.nodes.borrow().contains_key(&ins) { - self.find(&ins) + // pre-borrow the nodes as mutable + let mut nodes_borrow = self.nodes.borrow_mut(); + + // if the node already exists, return a reference to it + if let Some(subtree) = nodes_borrow.get(&ins) { + Rc::clone(subtree) } else { // only insert if it is not already in the lookup table - self.nodes - .borrow_mut() - .insert(ins.as_ref().clone(), Rc::clone(&ins)); + nodes_borrow.insert(ins.as_ref().clone(), Rc::clone(&ins)); Rc::clone(&ins) } } From 6c765c1efb50d7bf0a24ddae25fa0411e1f45ca8 Mon Sep 17 00:00:00 2001 From: Tim Beurskens Date: Wed, 23 Mar 2022 14:47:35 +0100 Subject: [PATCH 2/3] update version number --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8738a46..efc2306 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,7 +218,7 @@ checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "rsbdd" -version = "0.6.4" +version = "0.6.5" dependencies = [ "clap", "csv", diff --git a/Cargo.toml b/Cargo.toml index 9f9545d..983c34a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rsbdd" -version = "0.6.4" +version = "0.6.5" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 2afb5ac9e4696aa576abb3e86be8a56074ebf48b Mon Sep 17 00:00:00 2001 From: Tim Beurskens Date: Wed, 23 Mar 2022 14:53:49 +0100 Subject: [PATCH 3/3] add examples to automated build --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 52d7f98..a02a1db 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -17,6 +17,6 @@ jobs: steps: - uses: actions/checkout@v2 - name: Build - run: cargo build --verbose --release + run: cargo build --verbose --release --examples --bins --lib - name: Run tests run: cargo test --verbose --release