Skip to content

Commit

Permalink
Do not pollute hash table with expensive cost
Browse files Browse the repository at this point in the history
  • Loading branch information
lmondada committed Sep 26, 2023
1 parent d1862d8 commit 5f0c35c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/optimiser/taso.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ where
let new_circ_cost = (self.cost)(&new_circ);
circ_cnt += 1;
logger.log_progress(circ_cnt, Some(pq.len()), seen_hashes.len());
if !seen_hashes.insert(new_circ_hash, new_circ_cost) {
if (pq.len() > PRIORITY_QUEUE_CAPACITY / 2
&& new_circ_cost > *pq.max_cost().unwrap())
|| !seen_hashes.insert(new_circ_hash, new_circ_cost)
{
// Ignore this circuit: it's either too big or we've already seen it
continue;
}
pq.push_unchecked(new_circ, new_circ_hash, new_circ_cost);
Expand Down

0 comments on commit 5f0c35c

Please sign in to comment.