diff options
| author | Baptiste Fontaine | 2015-08-17 17:08:23 +0200 |
|---|---|---|
| committer | Baptiste Fontaine | 2015-08-18 00:18:22 +0200 |
| commit | 8ba0fb9fcf0d4d4d3497cf524b4c21c6fd4a86e3 (patch) | |
| tree | 9eb0a29a3ce1fc383bdc9cb53dd91039413cd3e5 /Library/Homebrew/cmd | |
| parent | f690b546215119c14c9626a5c89dbbc828eb3503 (diff) | |
| download | brew-8ba0fb9fcf0d4d4d3497cf524b4c21c6fd4a86e3.tar.bz2 | |
unnecessary calls to .select simplified
These are minor perf optimizations.
Closes Homebrew/homebrew#43028.
Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
Diffstat (limited to 'Library/Homebrew/cmd')
| -rw-r--r-- | Library/Homebrew/cmd/audit.rb | 8 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/cleanup.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/doctor.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/fetch.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/postinstall.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/prune.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/tap.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/update.rb | 4 |
8 files changed, 18 insertions, 11 deletions
diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb index babf58f62..49396224b 100644 --- a/Library/Homebrew/cmd/audit.rb +++ b/Library/Homebrew/cmd/audit.rb @@ -501,7 +501,7 @@ class FormulaAuditor } end - spec.patches.select(&:external?).each { |p| audit_patch(p) } + spec.patches.each { |p| audit_patch(p) if p.external? } end %w[Stable Devel].each do |name| @@ -1135,12 +1135,14 @@ class ResourceAuditor end # Use new-style archive downloads - urls.select { |u| u =~ %r{https://.*github.*/(?:tar|zip)ball/} && u !~ /\.git$/ }.each do |u| + urls.each do |u| + next unless u =~ %r{https://.*github.*/(?:tar|zip)ball/} && u !~ /\.git$/ problem "Use /archive/ URLs for GitHub tarballs (url is #{u})." end # Don't use GitHub .zip files - urls.select { |u| u =~ %r{https://.*github.*/(archive|releases)/.*\.zip$} && u !~ %r{releases/download} }.each do |u| + urls.each do |u| + next unless u =~ %r{https://.*github.*/(archive|releases)/.*\.zip$} && u !~ %r{releases/download} problem "Use GitHub tarballs rather than zipballs (url is #{u})." end end diff --git a/Library/Homebrew/cmd/cleanup.rb b/Library/Homebrew/cmd/cleanup.rb index 22ed236f9..f9203c68d 100644 --- a/Library/Homebrew/cmd/cleanup.rb +++ b/Library/Homebrew/cmd/cleanup.rb @@ -110,7 +110,8 @@ module Homebrew return unless HOMEBREW_CACHE_FORMULA.directory? candidates = HOMEBREW_CACHE_FORMULA.children lockfiles = candidates.select { |f| f.file? && f.extname == ".brewing" } - lockfiles.select(&:readable?).each do |file| + lockfiles.each do |file| + next unless file.readable? file.open.flock(File::LOCK_EX | File::LOCK_NB) && file.unlink end end @@ -118,7 +119,7 @@ module Homebrew def rm_DS_Store paths = Queue.new %w[Cellar Frameworks Library bin etc include lib opt sbin share var]. - map { |p| HOMEBREW_PREFIX/p }.select(&:exist?).each { |p| paths << p } + map { |p| HOMEBREW_PREFIX/p }.each { |p| paths << p if p.exist? } workers = (0...Hardware::CPU.cores).map do Thread.new do begin diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb index ecf66f668..7ceb88b7e 100644 --- a/Library/Homebrew/cmd/doctor.rb +++ b/Library/Homebrew/cmd/doctor.rb @@ -234,7 +234,8 @@ class Checks def check_for_broken_symlinks broken_symlinks = [] - Keg::PRUNEABLE_DIRECTORIES.select(&:directory?).each do |d| + Keg::PRUNEABLE_DIRECTORIES.each do |d| + next unless d.directory? d.find do |path| if path.symlink? && !path.resolved_path_exists? broken_symlinks << path diff --git a/Library/Homebrew/cmd/fetch.rb b/Library/Homebrew/cmd/fetch.rb index edf9c7f76..61c8bf781 100644 --- a/Library/Homebrew/cmd/fetch.rb +++ b/Library/Homebrew/cmd/fetch.rb @@ -24,7 +24,7 @@ module Homebrew else fetch_formula(f) f.resources.each { |r| fetch_resource(r) } - f.patchlist.select(&:external?).each { |p| fetch_patch(p) } + f.patchlist.each { |p| fetch_patch(p) if p.external? } end end end diff --git a/Library/Homebrew/cmd/postinstall.rb b/Library/Homebrew/cmd/postinstall.rb index f20b7ad54..1fdf7f67e 100644 --- a/Library/Homebrew/cmd/postinstall.rb +++ b/Library/Homebrew/cmd/postinstall.rb @@ -2,7 +2,7 @@ require "sandbox" module Homebrew def postinstall - ARGV.resolved_formulae.select(&:post_install_defined?).each { |f| run_post_install(f) } + ARGV.resolved_formulae.each { |f| run_post_install(f) if f.post_install_defined? } end def run_post_install(formula) diff --git a/Library/Homebrew/cmd/prune.rb b/Library/Homebrew/cmd/prune.rb index d6ece8305..0ad9f23e6 100644 --- a/Library/Homebrew/cmd/prune.rb +++ b/Library/Homebrew/cmd/prune.rb @@ -7,7 +7,8 @@ module Homebrew dirs = [] - Keg::PRUNEABLE_DIRECTORIES.select(&:directory?).each do |dir| + Keg::PRUNEABLE_DIRECTORIES.each do |dir| + next unless dir.directory? dir.find do |path| path.extend(ObserverPathnameExtension) if path.symlink? diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb index 35e12a120..d171f5461 100644 --- a/Library/Homebrew/cmd/tap.rb +++ b/Library/Homebrew/cmd/tap.rb @@ -46,7 +46,7 @@ module Homebrew def migrate_taps(options = {}) ignore = HOMEBREW_LIBRARY/"Formula/.gitignore" return unless ignore.exist? || options.fetch(:force, false) - (HOMEBREW_LIBRARY/"Formula").children.select(&:symlink?).each(&:unlink) + (HOMEBREW_LIBRARY/"Formula").children.each { |c| c.unlink if c.symlink? } ignore.unlink if ignore.exist? end diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb index cbd22a05c..b7f8932c3 100644 --- a/Library/Homebrew/cmd/update.rb +++ b/Library/Homebrew/cmd/update.rb @@ -30,7 +30,9 @@ module Homebrew # this procedure will be removed in the future if it seems unnecessasry rename_taps_dir_if_necessary - Tap.select(&:git?).each do |tap| + Tap.each do |tap| + next unless tap.git? + tap.path.cd do updater = Updater.new(tap.path) |
