Skip to content

Commit

Permalink
Merge pull request #90 from CocoaPods/gb-uniq-requirement-trees
Browse files Browse the repository at this point in the history
Make `Vertex#requirements` array unique
  • Loading branch information
segiddins authored Oct 29, 2017
2 parents ccd39a5 + fb27154 commit 1f66e42
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

##### Enhancements

* None.
* Reduce memory usage during resolution by making the `Vertex#requirements`
array unique.
[Grey Baker](https://github.com/greysteil)
[Jan Krutisch](https://github.com/halfbyte)

##### Bug Fixes

Expand Down
2 changes: 1 addition & 1 deletion lib/molinillo/dependency_graph/vertex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def initialize(name, payload)
# @return [Array<Object>] all of the requirements that required
# this vertex
def requirements
incoming_edges.map(&:requirement) + explicit_requirements
(incoming_edges.map(&:requirement) + explicit_requirements).uniq
end

# @return [Array<Edge>] the edges of {#graph} that have `self` as their
Expand Down
2 changes: 1 addition & 1 deletion lib/molinillo/resolution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def resolve_activated_specs
next unless vertex.payload

latest_version = vertex.payload.possibilities.reverse_each.find do |possibility|
vertex.requirements.uniq.all? { |req| requirement_satisfied_by?(req, activated, possibility) }
vertex.requirements.all? { |req| requirement_satisfied_by?(req, activated, possibility) }
end

activated.set_payload(vertex.name, latest_version)
Expand Down

0 comments on commit 1f66e42

Please sign in to comment.