minor perf improvements

Closes Homebrew/homebrew#47224.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
This commit is contained in:
Baptiste Fontaine 2015-12-21 13:33:03 +01:00
parent d09698f19f
commit 48681c3f3a
6 changed files with 11 additions and 8 deletions

View File

@ -36,7 +36,8 @@ MAXIMUM_STRING_MATCHES = 100
module Homebrew module Homebrew
def keg_contains(string, keg, ignores) def keg_contains(string, keg, ignores)
@put_string_exists_header, @put_filenames = nil @put_string_exists_header = nil
@put_filenames = nil
def print_filename(string, filename) def print_filename(string, filename)
unless @put_string_exists_header unless @put_string_exists_header

View File

@ -1298,13 +1298,14 @@ module Homebrew
first_warning = true first_warning = true
methods.each do |method| methods.each do |method|
begin unless checks.respond_to?(method)
out = checks.send(method)
rescue NoMethodError
Homebrew.failed = true Homebrew.failed = true
puts "No check available by the name: #{method}" puts "No check available by the name: #{method}"
next next
end end
out = checks.send(method)
unless out.nil? || out.empty? unless out.nil? || out.empty?
if first_warning if first_warning
$stderr.puts <<-EOS.undent $stderr.puts <<-EOS.undent

View File

@ -59,7 +59,7 @@ module Homebrew
url = "https://github.com/Homebrew/homebrew/pull/#{arg}" url = "https://github.com/Homebrew/homebrew/pull/#{arg}"
tap = CoreFormulaRepository.instance tap = CoreFormulaRepository.instance
elsif (testing_match = arg.match %r{brew.sh/job/Homebrew.*Testing/(\d+)/}) elsif (testing_match = arg.match %r{brew.sh/job/Homebrew.*Testing/(\d+)/})
_, testing_job = *testing_match testing_job = testing_match[1]
url = "https://github.com/Homebrew/homebrew/compare/master...BrewTestBot:testing-#{testing_job}" url = "https://github.com/Homebrew/homebrew/compare/master...BrewTestBot:testing-#{testing_job}"
tap = CoreFormulaRepository.instance tap = CoreFormulaRepository.instance
odie "Testing URLs require `--bottle`!" unless ARGV.include?("--bottle") odie "Testing URLs require `--bottle`!" unless ARGV.include?("--bottle")

View File

@ -33,7 +33,7 @@ class CompilerFailure
def self.create(spec, &block) def self.create(spec, &block)
# Non-Apple compilers are in the format fails_with compiler => version # Non-Apple compilers are in the format fails_with compiler => version
if spec.is_a?(Hash) if spec.is_a?(Hash)
_, major_version = spec.first major_version = spec.first[1]
name = "gcc-#{major_version}" name = "gcc-#{major_version}"
# so fails_with :gcc => '4.8' simply marks all 4.8 releases incompatible # so fails_with :gcc => '4.8' simply marks all 4.8 releases incompatible
version = "#{major_version}.999" version = "#{major_version}.999"

View File

@ -1271,7 +1271,7 @@ class Formula
"root_url" => bottle_spec.root_url, "root_url" => bottle_spec.root_url,
} }
bottle_info["files"] = {} bottle_info["files"] = {}
bottle_spec.collector.keys.each do |os| bottle_spec.collector.each_key do |os|
checksum = bottle_spec.collector[os] checksum = bottle_spec.collector[os]
bottle_info["files"][os] = { bottle_info["files"][os] = {
"url" => "#{bottle_spec.root_url}/#{Bottle::Filename.create(self, os, bottle_spec.revision)}", "url" => "#{bottle_spec.root_url}/#{Bottle::Filename.create(self, os, bottle_spec.revision)}",

View File

@ -24,7 +24,8 @@ module Utils
obj.inject({}) do |result, (key, val)| obj.inject({}) do |result, (key, val)|
key = key.respond_to?(:to_s) ? key.to_s : key key = key.respond_to?(:to_s) ? key.to_s : key
val = stringify_keys(val) val = stringify_keys(val)
result.merge!(key => val) result[key] = val
result
end end
else else
obj obj