Skip to content

Commit

Permalink
Merge pull request #5837 from dnkoutso/master
Browse files Browse the repository at this point in the history
Cache result of uses_swift and should_build
  • Loading branch information
segiddins committed Sep 14, 2016
2 parents 7bef87f + 49f6b10 commit ac9250e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Expand Up @@ -8,7 +8,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`

##### Enhancements

* None.
* 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)


##### Bug Fixes

Expand Down
16 changes: 11 additions & 5 deletions lib/cocoapods/target/pod_target.rb
Expand Up @@ -141,9 +141,12 @@ def product_module_name
# A target should not be build if it has no source files.
#
def should_build?
source_files = file_accessors.flat_map(&:source_files)
source_files -= file_accessors.flat_map(&:headers)
!source_files.empty?
return @should_build if defined? @should_build
@should_build = begin
source_files = file_accessors.flat_map(&:source_files)
source_files -= file_accessors.flat_map(&:headers)
!source_files.empty?
end
end

# @return [Array<Specification::Consumer>] the specification consumers for
Expand All @@ -156,8 +159,11 @@ def spec_consumers
# @return [Boolean] Whether the target uses Swift code
#
def uses_swift?
file_accessors.any? do |file_accessor|
file_accessor.source_files.any? { |sf| sf.extname == '.swift' }
return @uses_swift if defined? @uses_swift
@uses_swift = begin
file_accessors.any? do |file_accessor|
file_accessor.source_files.any? { |sf| sf.extname == '.swift' }
end
end
end

Expand Down

0 comments on commit ac9250e

Please sign in to comment.