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/info.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/info.rb')
| -rw-r--r-- | Library/Homebrew/cmd/info.rb | 8 | 
1 files changed, 4 insertions, 4 deletions
| diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index ad68dc8f4..7c483c378 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -118,7 +118,7 @@ module Homebrew      attrs << "pinned at #{f.pinned_version}" if f.pinned?      attrs << "keg-only" if f.keg_only? -    puts "#{f.full_name}: #{specs * ", "}#{" [#{attrs * ", "}]" if attrs.any?}" +    puts "#{f.full_name}: #{specs * ", "}#{" [#{attrs * ", "}]" unless attrs.empty?}"      puts f.desc if f.desc      puts "#{Tty.em}#{f.homepage}#{Tty.reset}" if f.homepage @@ -126,14 +126,14 @@ module Homebrew      puts "Conflicts with: #{conflicts*", "}" unless conflicts.empty?      kegs = f.installed_kegs.sort_by(&:version) -    if kegs.any? +    if kegs.empty? +      puts "Not installed" +    else        kegs.each do |keg|          puts "#{keg} (#{keg.abv})#{" *" if keg.linked?}"          tab = Tab.for_keg(keg).to_s          puts "  #{tab}" unless tab.empty?        end -    else -      puts "Not installed"      end      puts "From: #{Tty.em}#{github_info(f)}#{Tty.reset}" | 
