Skip to content

Commit

Permalink
tweak path construction efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmgray committed Sep 1, 2023
1 parent d0be8f8 commit bea257e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,15 +674,16 @@ impl ContractionProcessor {
// contractions[m] for borrowing reasons, we check
// against a non-delayed score lookup so we don't
// overwrite best scores within the same iteration
let new_best = match best_scores.get(&new_subgraph) {
let found_new_best = match best_scores.get(&new_subgraph) {
Some(current_score) => new_score < *current_score,
None => true,
};
if new_best {
if found_new_best {
best_scores.insert(new_subgraph.clone(), new_score);
// only need the path if updating
let mut new_path = ipath.clone();
new_path.extend(jpath.clone());
let mut new_path: BitPath = Vec::with_capacity(ipath.len() + jpath.len() + 1);
new_path.extend_from_slice(&ipath);
new_path.extend_from_slice(&jpath);
new_path.push((isubgraph.clone(), jsubgraph.clone()));
contractions_m_temp
.push((new_subgraph, (new_legs, new_score, new_path)));
Expand Down

0 comments on commit bea257e

Please sign in to comment.