Unverified Commit 979a1465 authored by Samuel Giddins's avatar Samuel Giddins Committed by GitHub

Merge pull request #7540 from dnkoutso/flat_map_preferred

Use `flat_map` instead of flatten in some cases
parents 46cbc382 17c1e997
...@@ -219,8 +219,8 @@ module Pod ...@@ -219,8 +219,8 @@ module Pod
# generated as result of the analyzer. # generated as result of the analyzer.
# #
def pod_targets def pod_targets
aggregate_target_pod_targets = aggregate_targets.map(&:pod_targets).flatten aggregate_target_pod_targets = aggregate_targets.flat_map(&:pod_targets)
test_dependent_targets = aggregate_target_pod_targets.map(&:test_dependent_targets).flatten test_dependent_targets = aggregate_target_pod_targets.flat_map(&:test_dependent_targets)
(aggregate_target_pod_targets + test_dependent_targets).uniq (aggregate_target_pod_targets + test_dependent_targets).uniq
end end
......
...@@ -340,7 +340,7 @@ module Pod ...@@ -340,7 +340,7 @@ module Pod
end end
unless embedded_targets_missing_hosts.empty? unless embedded_targets_missing_hosts.empty?
embedded_targets_missing_hosts_product_types = Set.new embedded_targets_missing_hosts.map(&:user_targets).flatten.map(&:symbol_type) embedded_targets_missing_hosts_product_types = Set.new embedded_targets_missing_hosts.flat_map(&:user_targets).map(&:symbol_type)
target_names = embedded_targets_missing_hosts.map do |target| target_names = embedded_targets_missing_hosts.map do |target|
target.name.sub('Pods-', '') # Make the target names more recognizable to the user target.name.sub('Pods-', '') # Make the target names more recognizable to the user
end.join ', ' end.join ', '
......
...@@ -182,7 +182,7 @@ module Pod ...@@ -182,7 +182,7 @@ module Pod
# specs platform combinations. # specs platform combinations.
# #
def file_accessors def file_accessors
@file_accessors ||= pod_targets.map(&:file_accessors).flatten.compact @file_accessors ||= pod_targets.flat_map(&:file_accessors).compact
end end
# Adds file references to the list of the paths returned by the file # Adds file references to the list of the paths returned by the file
......
...@@ -75,8 +75,8 @@ module Pod ...@@ -75,8 +75,8 @@ module Pod
input_paths = [] input_paths = []
output_paths = [] output_paths = []
unless framework_paths.empty? unless framework_paths.empty?
input_paths = [script_path, *framework_paths.map { |fw| [fw[:input_path], fw[:dsym_input_path]] }.flatten.compact] input_paths = [script_path, *framework_paths.flat_map { |fw| [fw[:input_path], fw[:dsym_input_path]] }.compact]
output_paths = framework_paths.map { |fw| [fw[:output_path], fw[:dsym_output_path]] }.flatten.compact output_paths = framework_paths.flat_map { |fw| [fw[:output_path], fw[:dsym_output_path]] }.compact
end end
UserProjectIntegrator::TargetIntegrator.validate_input_output_path_limit(input_paths, output_paths) UserProjectIntegrator::TargetIntegrator.validate_input_output_path_limit(input_paths, output_paths)
UserProjectIntegrator::TargetIntegrator.create_or_update_embed_frameworks_script_phase_to_target(native_target, script_path, input_paths, output_paths) UserProjectIntegrator::TargetIntegrator.create_or_update_embed_frameworks_script_phase_to_target(native_target, script_path, input_paths, output_paths)
...@@ -95,7 +95,7 @@ module Pod ...@@ -95,7 +95,7 @@ module Pod
# @return [Array<Hash<Symbol=>String>] an array of all combined script phases from the specs. # @return [Array<Hash<Symbol=>String>] an array of all combined script phases from the specs.
# #
def script_phases_for_specs(specs) def script_phases_for_specs(specs)
specs.map { |spec| spec.consumer(target.platform) }.map(&:script_phases).flatten specs.flat_map { |spec| spec.consumer(target.platform).script_phases }
end end
end end
end end
......
...@@ -196,9 +196,9 @@ module Pod ...@@ -196,9 +196,9 @@ module Pod
# shipped with the Pod. # shipped with the Pod.
# #
def vendored_frameworks_headers def vendored_frameworks_headers
vendored_frameworks.map do |framework| vendored_frameworks.flat_map do |framework|
self.class.vendored_frameworks_headers(framework) self.class.vendored_frameworks_headers(framework)
end.flatten.uniq end.uniq
end end
# @return [Array<Pathname>] The paths of the library bundles that come # @return [Array<Pathname>] The paths of the library bundles that come
......
...@@ -162,7 +162,7 @@ module Pod ...@@ -162,7 +162,7 @@ module Pod
# @return [Array<Specification>] The specifications used by this aggregate target. # @return [Array<Specification>] The specifications used by this aggregate target.
# #
def specs def specs
pod_targets.map(&:specs).flatten pod_targets.flat_map(&:specs)
end end
# @return [Hash{Symbol => Array<Specification>}] The pod targets for each # @return [Hash{Symbol => Array<Specification>}] The pod targets for each
......
...@@ -28,7 +28,7 @@ module Pod ...@@ -28,7 +28,7 @@ module Pod
result = @analyzer.analyze result = @analyzer.analyze
aggregate_targets = result.targets aggregate_targets = result.targets
pod_targets = aggregate_targets.map(&:pod_targets).flatten.uniq pod_targets = aggregate_targets.flat_map(&:pod_targets).uniq
sandbox.create_file_accessors(pod_targets) sandbox.create_file_accessors(pod_targets)
TargetValidator.new(aggregate_targets, pod_targets) TargetValidator.new(aggregate_targets, pod_targets)
......
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