Skip to content

Commit

Permalink
[Lockfile] Cache the spec repos by pod so the hash only needs to be t…
Browse files Browse the repository at this point in the history
…raversed once
  • Loading branch information
segiddins committed Mar 5, 2018
1 parent c80c5cc commit d9b3aa0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/cocoapods-core/lockfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def version(pod_name)
# @return [Nil] If there is no source stored for the given name.
#
def spec_repo(pod_name)
pods_by_spec_repo.detect { |key, values| break key if values.include?(pod_name) }
spec_repos_by_pod[pod_name]
end

# Returns the checksum for the given Pod.
Expand Down Expand Up @@ -248,6 +248,17 @@ def checksum_data
internal_data['SPEC CHECKSUMS'] || {}
end

# @return [Hash{String => String}] A hash containing the spec repo used for the specification
# by the name of the root spec.
#
def spec_repos_by_pod
@spec_repos_by_pod ||= pods_by_spec_repo.each_with_object({}) do |(spec_repo, pods), spec_repos_by_pod|
pods.each do |pod|
spec_repos_by_pod[pod] = spec_repo
end
end
end

#-------------------------------------------------------------------------#

# !@group Comparison with a Podfile
Expand Down

0 comments on commit d9b3aa0

Please sign in to comment.