diff options
| author | Xu Cheng | 2016-08-05 22:01:32 +0800 | 
|---|---|---|
| committer | GitHub | 2016-08-05 22:01:32 +0800 | 
| commit | a8566c9848122474b92fc8989eec196d5f4fb69b (patch) | |
| tree | 896c040fb575962be0aeb27bc9a99454f3514d73 /Library/Homebrew/cmd/outdated.rb | |
| parent | 38209aadbfe4fd0c6772467c4bc5c63325d53f6c (diff) | |
| download | brew-a8566c9848122474b92fc8989eec196d5f4fb69b.tar.bz2 | |
various: eliminate the usage of `any?` (#638)
`any?` is not the opposite of `empty?`. Besides the case that
`[false, nil].any?` will return false, `any?`(O(n)) has much worse
performance than `empty?`(O(1)).
Diffstat (limited to 'Library/Homebrew/cmd/outdated.rb')
| -rw-r--r-- | Library/Homebrew/cmd/outdated.rb | 8 | 
1 files changed, 6 insertions, 2 deletions
| diff --git a/Library/Homebrew/cmd/outdated.rb b/Library/Homebrew/cmd/outdated.rb index dfd61226a..a318b65f6 100644 --- a/Library/Homebrew/cmd/outdated.rb +++ b/Library/Homebrew/cmd/outdated.rb @@ -17,13 +17,17 @@ require "keg"  module Homebrew    def outdated -    formulae = ARGV.resolved_formulae.any? ? ARGV.resolved_formulae : Formula.installed +    formulae = if ARGV.resolved_formulae.empty? +      Formula.installed +    else +      ARGV.resolved_formulae +    end      if ARGV.json == "v1"        outdated = print_outdated_json(formulae)      else        outdated = print_outdated(formulae)      end -    Homebrew.failed = ARGV.resolved_formulae.any? && outdated.any? +    Homebrew.failed = !ARGV.resolved_formulae.empty? && !outdated.empty?    end    def print_outdated(formulae) | 
