Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: don't redundantly add incompatibilities (1.5x speedup) #29

Merged
merged 1 commit into from
Oct 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub fn resolve<P: Package, V: Version>(
version: impl Into<V>,
) -> Result<Map<P, V>, PubGrubError<P, V>> {
let mut state = State::init(package.clone(), version.into());
let mut added_dependencies: Map<P, Set<V>> = Map::default();
let mut next = package;
loop {
state.unit_propagation(next)?;
Expand Down Expand Up @@ -145,8 +146,14 @@ pub fn resolve<P: Package, V: Version>(
let start_id = state.incompatibility_store.len();
let dep_incompats =
Incompatibility::from_dependencies(start_id, p.clone(), v.clone(), &dependencies);
for incompat in dep_incompats.iter() {
state.add_incompatibility(|_| incompat.clone());
if added_dependencies
.entry(p.clone())
.or_default()
.insert(v.clone())
{
for incompat in dep_incompats.iter() {
state.add_incompatibility(|_| incompat.clone());
}
}
if dep_incompats
.iter()
Expand Down