Skip to content

Commit

Permalink
Simplified loop
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Nov 21, 2023
1 parent 8711f89 commit 00b3516
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,17 @@ func (ar *Resolver[R, D]) resolve(solution map[string]R, depsToProcess []D, prob
releases.SortDescent()

debug("releases matching criteria: %s", releases)
backtracking_loop:
for _, release := range releases {
deps := release.GetDependencies()
debug("try with %s %s", release, deps)

missingDep := false
for _, dep := range deps {
if _, ok := ar.releases[dep.GetName()]; !ok {
debug("%s did not work, becuase his dependency %s does not exists", release, dep.GetName())
missingDep = true
break
releaseDeps := release.GetDependencies()
debug("try with %s %s", release, releaseDeps)

for _, releaseDep := range releaseDeps {
if _, ok := ar.releases[releaseDep.GetName()]; !ok {
debug("%s did not work, becuase his dependency %s does not exists", release, releaseDep.GetName())
continue backtracking_loop
}
}
if missingDep {
continue
}

solution[depName] = release
newDepsToProcess := append(depsToProcess[1:], deps...)
Expand Down

0 comments on commit 00b3516

Please sign in to comment.