mirror of https://github.com/rails/rails
Merge pull request #42083 from SkipKayhil/use-filter-map
use ruby 2.7's filter_map instead of select + map
This commit is contained in:
commit
4c91c7f2e1
|
@ -259,6 +259,9 @@ Performance/FlatMap:
|
|||
Performance/MapCompact:
|
||||
Enabled: true
|
||||
|
||||
Performance/SelectMap:
|
||||
Enabled: true
|
||||
|
||||
Performance/RedundantMerge:
|
||||
Enabled: true
|
||||
|
||||
|
|
|
@ -24,10 +24,8 @@ module ActionView #:nodoc:
|
|||
|
||||
private
|
||||
def template_glob(glob)
|
||||
@hash.keys.select do |path|
|
||||
File.fnmatch(glob, path)
|
||||
end.map do |fixture|
|
||||
"/#{fixture}"
|
||||
@hash.keys.filter_map do |path|
|
||||
"/#{path}" if File.fnmatch(glob, path)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ module Kindle
|
|||
puts "=> Arranging html pages in document order"
|
||||
toc = File.read("toc.ncx")
|
||||
doc = Nokogiri::XML(toc).xpath("//ncx:content", "ncx" => "http://www.daisy.org/z3986/2005/ncx/")
|
||||
html_pages = doc.select { |c| c[:src] }.map { |c| c[:src] }.uniq
|
||||
html_pages = doc.filter_map { |c| c[:src] }.uniq
|
||||
|
||||
generate_front_matter(html_pages)
|
||||
|
||||
|
|
|
@ -34,9 +34,7 @@ class Rails::InfoController < Rails::ApplicationController # :nodoc:
|
|||
|
||||
private
|
||||
def match_route
|
||||
_routes.routes.select { |route|
|
||||
yield route.path
|
||||
}.map { |route| route.path.spec.to_s }
|
||||
_routes.routes.filter_map { |route| route.path.spec.to_s if yield route.path }
|
||||
end
|
||||
|
||||
def with_leading_slash(path)
|
||||
|
|
|
@ -63,7 +63,9 @@ module Rails
|
|||
private
|
||||
def extract_filters(argv)
|
||||
# Extract absolute and relative paths but skip -n /.*/ regexp filters.
|
||||
argv.select { |arg| path_argument?(arg) && !regexp_filter?(arg) }.map do |path|
|
||||
argv.filter_map do |path|
|
||||
next unless path_argument?(path) && !regexp_filter?(path)
|
||||
|
||||
path = path.tr("\\", "/")
|
||||
case
|
||||
when /(:\d+)+$/.match?(path)
|
||||
|
|
Loading…
Reference in New Issue