Cache result of uses_swift and should_build

parent f5cc0b09
...@@ -8,7 +8,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -8,7 +8,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Enhancements ##### 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 ##### Bug Fixes
......
...@@ -141,9 +141,12 @@ module Pod ...@@ -141,9 +141,12 @@ module Pod
# A target should not be build if it has no source files. # A target should not be build if it has no source files.
# #
def should_build? def should_build?
source_files = file_accessors.flat_map(&:source_files) return @should_build if defined? @should_build
source_files -= file_accessors.flat_map(&:headers) @should_build = begin
!source_files.empty? source_files = file_accessors.flat_map(&:source_files)
source_files -= file_accessors.flat_map(&:headers)
!source_files.empty?
end
end end
# @return [Array<Specification::Consumer>] the specification consumers for # @return [Array<Specification::Consumer>] the specification consumers for
...@@ -156,8 +159,11 @@ module Pod ...@@ -156,8 +159,11 @@ module Pod
# @return [Boolean] Whether the target uses Swift code # @return [Boolean] Whether the target uses Swift code
# #
def uses_swift? def uses_swift?
file_accessors.any? do |file_accessor| return @uses_swift if defined? @uses_swift
file_accessor.source_files.any? { |sf| sf.extname == '.swift' } @uses_swift = begin
file_accessors.any? do |file_accessor|
file_accessor.source_files.any? { |sf| sf.extname == '.swift' }
end
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment