Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Cache result of include_in_build_config and inhibit_warnings
  • Loading branch information
dnkoutso committed Sep 23, 2016
1 parent 77d6a4a commit 3e4e76f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`

##### Enhancements

* Cache result of inhibit_warnings and include_in_build_config to speed up pod install.
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#5857](https://github.com/CocoaPods/CocoaPods/pull/5857)

* Cache result of uses_swift and should_build to speed up pod install.
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#5837](https://github.com/CocoaPods/CocoaPods/pull/5837)
Expand Down
11 changes: 11 additions & 0 deletions lib/cocoapods/target/pod_target.rb
Expand Up @@ -47,6 +47,7 @@ def initialize(specs, target_definitions, sandbox, scope_suffix = nil)
@file_accessors = []
@resource_bundle_targets = []
@dependent_targets = []
@build_config_cache = {}
end

# @param [Hash{Array => PodTarget}] cache
Expand Down Expand Up @@ -222,13 +223,20 @@ def recursive_dependent_targets
# The name of the build configuration.
#
def include_in_build_config?(target_definition, configuration_name)
key = [target_definition.label, configuration_name]
if @build_config_cache.has_key?(key)
return @build_config_cache[key]
end

whitelists = target_definition_dependencies(target_definition).map do |dependency|
target_definition.pod_whitelisted_for_configuration?(dependency.name, configuration_name)
end.uniq

if whitelists.empty?
@build_config_cache[key] = true
return true
elsif whitelists.count == 1
@build_config_cache[key] = whitelists.first
whitelists.first
else
raise Informative, "The subspecs of `#{pod_name}` are linked to " \
Expand All @@ -243,13 +251,16 @@ def include_in_build_config?(target_definition, configuration_name)
# @return [Bool]
#
def inhibit_warnings?
return @inhibit_warnings if defined? @inhibit_warnings
whitelists = target_definitions.map do |target_definition|
target_definition.inhibits_warnings_for_pod?(root_spec.name)
end.uniq

if whitelists.empty?
@inhibit_warnings = false
return false
elsif whitelists.count == 1
@inhibit_warnings = whitelists.first
whitelists.first
else
UI.warn "The pod `#{pod_name}` is linked to different targets " \
Expand Down

0 comments on commit 3e4e76f

Please sign in to comment.