Skip to content

Commit

Permalink
[Source] Fixed slowness.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiopelosin committed Oct 4, 2012
1 parent 8f8e540 commit 131b758
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -15,6 +15,7 @@
[#570](https://github.com/CocoaPods/CocoaPods/issues/570)
- Fixed a crash for `pod outdated`.
[#567](https://github.com/CocoaPods/CocoaPods/issues/567)
- Fixed an issue that lead to excessively slow sets computation.

## 0.15.0

Expand Down
18 changes: 15 additions & 3 deletions lib/cocoapods/source.rb
Expand Up @@ -128,10 +128,22 @@ def all_pods

# @return [Array<Set>] The sets for all the pods available.
#
# @note Implementation detail: The sources don't cache their values
# because they might change in response to an update. Therefore
# this method to prevent slowness caches the values before
# processing them.
#
def all_sets
all_pods.map do |pod|
sources = all.select{ |s| s.pods.include?(pod) }.compact
Specification::Set.new(pod, sources)
pods_by_source = {}
all.each do |source|
pods_by_source[source] = source.pods
end
sources = pods_by_source.keys
pods = pods_by_source.values.flatten.uniq

pods.map do |pod|
pod_sources = sources.select{ |s| pods_by_source[s].include?(pod) }.compact
Specification::Set.new(pod, pod_sources)
end
end

Expand Down

0 comments on commit 131b758

Please sign in to comment.