[rubygems/rubygems] More aggressive Performance/FlatMap
cop configuration
https://github.com/rubygems/rubygems/commit/d8d68cc00e
This commit is contained in:
parent
11e522b913
commit
4addaaf4df
@ -581,12 +581,12 @@ module Bundler
|
||||
Bundler.rubygems.load_plugins
|
||||
|
||||
requested_path_gems = definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
|
||||
path_plugin_files = requested_path_gems.map do |spec|
|
||||
path_plugin_files = requested_path_gems.flat_map do |spec|
|
||||
spec.matches_for_glob("rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
|
||||
rescue TypeError
|
||||
error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
|
||||
raise Gem::InvalidSpecificationException, error_message
|
||||
end.flatten
|
||||
end
|
||||
Bundler.rubygems.load_plugin_files(path_plugin_files)
|
||||
Bundler.rubygems.load_env_plugins
|
||||
@load_plugins_ran = true
|
||||
|
@ -89,11 +89,11 @@ module Bundler
|
||||
|
||||
if broken_links.any?
|
||||
message = "The following gems are missing OS dependencies:"
|
||||
broken_links.map do |spec, paths|
|
||||
broken_links.flat_map do |spec, paths|
|
||||
paths.uniq.map do |path|
|
||||
"\n * #{spec.name}: #{path}"
|
||||
end
|
||||
end.flatten.sort.each {|m| message += m }
|
||||
end.sort.each {|m| message += m }
|
||||
raise ProductionError, message
|
||||
elsif !permissions_valid
|
||||
Bundler.ui.info "No issues found with the installed bundle"
|
||||
|
@ -345,7 +345,7 @@ module Bundler
|
||||
end
|
||||
|
||||
def groups
|
||||
dependencies.map(&:groups).flatten.uniq
|
||||
dependencies.flat_map(&:groups).uniq
|
||||
end
|
||||
|
||||
def lock(file_or_preserve_unknown_sections = false, preserve_unknown_sections_or_unused = false)
|
||||
|
@ -28,7 +28,7 @@ module Bundler
|
||||
private
|
||||
|
||||
def paths
|
||||
@specs.map do |spec|
|
||||
@specs.flat_map do |spec|
|
||||
next if spec.name == "bundler"
|
||||
Array(spec.require_paths).map do |path|
|
||||
gem_path(path, spec).
|
||||
@ -36,7 +36,7 @@ module Bundler
|
||||
sub(extensions_dir, 'extensions/\k<platform>/#{Gem.extension_api_version}')
|
||||
# This is a static string intentionally. It's interpolated at a later time.
|
||||
end
|
||||
end.flatten.compact
|
||||
end.compact
|
||||
end
|
||||
|
||||
def version_dir
|
||||
|
@ -79,7 +79,7 @@ module Bundler
|
||||
def solve_versions(root:, logger:)
|
||||
solver = PubGrub::VersionSolver.new(source: self, root: root, logger: logger)
|
||||
result = solver.solve
|
||||
resolved_specs = result.map {|package, version| version.to_specs(package) }.flatten
|
||||
resolved_specs = result.flat_map {|package, version| version.to_specs(package) }
|
||||
resolved_specs |= @base.specs_compatible_with(SpecSet.new(resolved_specs))
|
||||
rescue PubGrub::SolveFailure => e
|
||||
incompatibility = e.incompatibility
|
||||
|
@ -38,9 +38,9 @@ module Bundler
|
||||
end
|
||||
|
||||
def dependencies
|
||||
@dependencies ||= @specs.map do |spec|
|
||||
@dependencies ||= @specs.flat_map do |spec|
|
||||
__dependencies(spec) + metadata_dependencies(spec)
|
||||
end.flatten.uniq.sort
|
||||
end.uniq.sort
|
||||
end
|
||||
|
||||
def ==(other)
|
||||
|
@ -91,7 +91,7 @@ module Bundler
|
||||
end
|
||||
|
||||
def rubygems_remotes
|
||||
rubygems_sources.map(&:remotes).flatten.uniq
|
||||
rubygems_sources.flat_map(&:remotes).uniq
|
||||
end
|
||||
|
||||
def all_sources
|
||||
|
@ -496,9 +496,9 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||
|
||||
gem_specifications = @gemdeps ? Gem.loaded_specs.values : Gem::Specification.stubs
|
||||
|
||||
files.concat gem_specifications.map {|spec|
|
||||
files.concat gem_specifications.flat_map {|spec|
|
||||
spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}")
|
||||
}.flatten
|
||||
}
|
||||
|
||||
# $LOAD_PATH might contain duplicate entries or reference
|
||||
# the spec dirs directly, so we prune.
|
||||
@ -509,9 +509,9 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||
|
||||
def self.find_files_from_load_path(glob) # :nodoc:
|
||||
glob_with_suffixes = "#{glob}#{Gem.suffix_pattern}"
|
||||
$LOAD_PATH.map do |load_path|
|
||||
$LOAD_PATH.flat_map do |load_path|
|
||||
Gem::Util.glob_files_in_dir(glob_with_suffixes, load_path)
|
||||
end.flatten.select {|file| File.file? file }
|
||||
end.select {|file| File.file? file }
|
||||
end
|
||||
|
||||
##
|
||||
@ -531,9 +531,9 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||
|
||||
files = find_files_from_load_path glob if check_load_path
|
||||
|
||||
files.concat Gem::Specification.latest_specs(true).map {|spec|
|
||||
files.concat Gem::Specification.latest_specs(true).flat_map {|spec|
|
||||
spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}")
|
||||
}.flatten
|
||||
}
|
||||
|
||||
# $LOAD_PATH might contain duplicate entries or reference
|
||||
# the spec dirs directly, so we prune.
|
||||
|
@ -113,9 +113,9 @@ If no gems are named all gems in GEM_HOME are cleaned.
|
||||
@candidate_gems = if options[:args].empty?
|
||||
Gem::Specification.to_a
|
||||
else
|
||||
options[:args].map do |gem_name|
|
||||
options[:args].flat_map do |gem_name|
|
||||
Gem::Specification.find_all_by_name gem_name
|
||||
end.flatten
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -189,8 +189,8 @@ prefix or only the files that are requireable.
|
||||
end
|
||||
|
||||
def specification_directories # :nodoc:
|
||||
options[:specdirs].map do |i|
|
||||
options[:specdirs].flat_map do |i|
|
||||
[i, File.join(i, "specifications")]
|
||||
end.flatten
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -120,9 +120,9 @@ extensions will be restored.
|
||||
elsif options[:only_missing_extensions]
|
||||
specification_record.select(&:missing_extensions?)
|
||||
else
|
||||
get_all_gem_names.sort.map do |gem_name|
|
||||
get_all_gem_names.sort.flat_map do |gem_name|
|
||||
specification_record.find_all_by_name(gem_name, options[:version]).reverse
|
||||
end.flatten
|
||||
end
|
||||
end
|
||||
|
||||
specs = specs.select {|spec| spec.platform == RUBY_ENGINE || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY }
|
||||
|
@ -64,9 +64,9 @@ Use --overwrite to force rebuilding of documentation.
|
||||
specs = if options[:all]
|
||||
Gem::Specification.to_a
|
||||
else
|
||||
get_all_gem_names.map do |name|
|
||||
get_all_gem_names.flat_map do |name|
|
||||
Gem::Specification.find_by_name name, options[:version]
|
||||
end.flatten.uniq
|
||||
end.uniq
|
||||
end
|
||||
|
||||
if specs.empty?
|
||||
|
@ -59,7 +59,7 @@ class Gem::Resolver
|
||||
def self.compose_sets(*sets)
|
||||
sets.compact!
|
||||
|
||||
sets = sets.map do |set|
|
||||
sets = sets.flat_map do |set|
|
||||
case set
|
||||
when Gem::Resolver::BestSet then
|
||||
set
|
||||
@ -68,7 +68,7 @@ class Gem::Resolver
|
||||
else
|
||||
set
|
||||
end
|
||||
end.flatten
|
||||
end
|
||||
|
||||
case sets.length
|
||||
when 0 then
|
||||
|
@ -44,16 +44,16 @@ class Gem::Resolver::ComposedSet < Gem::Resolver::Set
|
||||
end
|
||||
|
||||
def errors
|
||||
@errors + @sets.map(&:errors).flatten
|
||||
@errors + @sets.flat_map(&:errors)
|
||||
end
|
||||
|
||||
##
|
||||
# Finds all specs matching +req+ in all sets.
|
||||
|
||||
def find_all(req)
|
||||
@sets.map do |s|
|
||||
@sets.flat_map do |s|
|
||||
s.find_all req
|
||||
end.flatten
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -65,11 +65,11 @@ class Gem::Resolver::IndexSet < Gem::Resolver::Set
|
||||
|
||||
q.breakable
|
||||
|
||||
names = @all.values.map do |tuples|
|
||||
names = @all.values.flat_map do |tuples|
|
||||
tuples.map do |_, tuple|
|
||||
tuple.full_name
|
||||
end
|
||||
end.flatten
|
||||
end
|
||||
|
||||
q.seplist names do |name|
|
||||
q.text name
|
||||
|
@ -1014,7 +1014,7 @@ class Gem::Specification < Gem::BasicSpecification
|
||||
end
|
||||
|
||||
def self.unresolved_specs
|
||||
unresolved_deps.values.map(&:to_specs).flatten
|
||||
unresolved_deps.values.flat_map(&:to_specs)
|
||||
end
|
||||
private_class_method :unresolved_specs
|
||||
|
||||
@ -1073,7 +1073,7 @@ class Gem::Specification < Gem::BasicSpecification
|
||||
result[spec.name] = spec
|
||||
end
|
||||
|
||||
result.map(&:last).flatten.sort_by(&:name)
|
||||
result.flat_map(&:last).sort_by(&:name)
|
||||
end
|
||||
|
||||
##
|
||||
@ -1770,7 +1770,7 @@ class Gem::Specification < Gem::BasicSpecification
|
||||
# Returns all specs that matches this spec's runtime dependencies.
|
||||
|
||||
def dependent_specs
|
||||
runtime_dependencies.map(&:to_specs).flatten
|
||||
runtime_dependencies.flat_map(&:to_specs)
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -67,14 +67,14 @@ class CompactIndexAPI < Endpoint
|
||||
@gems ||= {}
|
||||
@gems[gem_repo] ||= begin
|
||||
specs = Bundler::Deprecate.skip_during do
|
||||
%w[specs.4.8 prerelease_specs.4.8].map do |filename|
|
||||
%w[specs.4.8 prerelease_specs.4.8].flat_map do |filename|
|
||||
spec_index = gem_repo.join(filename)
|
||||
next [] unless File.exist?(spec_index)
|
||||
|
||||
Marshal.load(File.binread(spec_index)).map do |name, version, platform|
|
||||
load_spec(name, version, platform, gem_repo)
|
||||
end
|
||||
end.flatten
|
||||
end
|
||||
end
|
||||
|
||||
specs.group_by(&:name).map do |name, versions|
|
||||
|
Loading…
x
Reference in New Issue
Block a user