diff --git a/src/internal/core.rs b/src/internal/core.rs index fa986f34..ca598564 100644 --- a/src/internal/core.rs +++ b/src/internal/core.rs @@ -131,7 +131,14 @@ impl State { break; } Relation::AlmostSatisfied(package_almost) => { - self.unit_propagation_buffer.push(package_almost.clone()); + // Add `package_almost` to the `unit_propagation_buffer` set. + // Putting items in `unit_propagation_buffer` more than once waste cycles, + // but so does checking for duplicates. + // In practice the most common pathology is adding the same package repeatedly. + // So we only check if it is duplicated with the last item. + if self.unit_propagation_buffer.last() != Some(&package_almost) { + self.unit_propagation_buffer.push(package_almost.clone()); + } // Add (not term) to the partial solution with incompat as cause. self.partial_solution.add_derivation( package_almost,