mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Improve performance of Formula#to_hash
This commit is contained in:
parent
eadbe0f184
commit
0c08a3cccb
@ -537,8 +537,7 @@ class Formula
|
|||||||
sig { returns(T::Array[String]) }
|
sig { returns(T::Array[String]) }
|
||||||
def oldnames
|
def oldnames
|
||||||
@oldnames ||= if tap
|
@oldnames ||= if tap
|
||||||
T.must(tap).formula_renames
|
T.must(tap).formula_oldnames.fetch(name, [])
|
||||||
.flat_map { |old_name, new_name| (new_name == name) ? old_name : [] }
|
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
@ -2237,7 +2236,7 @@ class Formula
|
|||||||
"versions" => {
|
"versions" => {
|
||||||
"stable" => stable&.version&.to_s,
|
"stable" => stable&.version&.to_s,
|
||||||
"head" => head&.version&.to_s,
|
"head" => head&.version&.to_s,
|
||||||
"bottle" => !bottle_specification.checksums.empty?,
|
"bottle" => bottle_defined?,
|
||||||
},
|
},
|
||||||
"urls" => {},
|
"urls" => {},
|
||||||
"revision" => revision,
|
"revision" => revision,
|
||||||
@ -2434,7 +2433,7 @@ class Formula
|
|||||||
"files" => {},
|
"files" => {},
|
||||||
}
|
}
|
||||||
bottle_spec.collector.each_tag do |tag|
|
bottle_spec.collector.each_tag do |tag|
|
||||||
tag_spec = bottle_spec.collector.specification_for(tag)
|
tag_spec = bottle_spec.collector.specification_for(tag, no_older_versions: true)
|
||||||
os_cellar = tag_spec.cellar
|
os_cellar = tag_spec.cellar
|
||||||
os_cellar = os_cellar.inspect if os_cellar.is_a?(Symbol)
|
os_cellar = os_cellar.inspect if os_cellar.is_a?(Symbol)
|
||||||
|
|
||||||
|
@ -767,6 +767,15 @@ class Tap
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Hash with tap formula old names. Reverse of {#formula_renames}.
|
||||||
|
sig { returns(T::Hash[String, T::Array[String]]) }
|
||||||
|
def formula_oldnames
|
||||||
|
@formula_oldnames ||= formula_renames.each_with_object({}) do |(old_name, new_name), hash|
|
||||||
|
hash[new_name] ||= []
|
||||||
|
hash[new_name] << old_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Hash with tap migrations.
|
# Hash with tap migrations.
|
||||||
sig { returns(Hash) }
|
sig { returns(Hash) }
|
||||||
def tap_migrations
|
def tap_migrations
|
||||||
|
@ -209,10 +209,7 @@ module Utils
|
|||||||
|
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
def macos?
|
def macos?
|
||||||
to_macos_version
|
MacOSVersion::SYMBOLS.key?(system)
|
||||||
true
|
|
||||||
rescue MacOSVersion::Error
|
|
||||||
false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user