Use each_with_object

This commit is contained in:
Douglas Eichelberger 2024-01-22 10:41:48 -08:00
parent 1a40468ce4
commit e574904cb7
2 changed files with 6 additions and 18 deletions

View File

@ -1,16 +1,5 @@
# typed: strict # typed: strict
module Enumerable
requires_ancestor { Object }
sig {
type_parameters(:key).params(
block: T.nilable(T.proc.params(o: Enumerable::Elem).returns(T.type_parameter(:key))),
).returns(T::Hash[T.type_parameter(:key), Enumerable::Elem])
}
def index_by(&block); end
end
class Hash class Hash
sig { returns(T::Hash[Hash::K, Hash::V]) } sig { returns(T::Hash[Hash::K, Hash::V]) }
def compact_blank; end def compact_blank; end

View File

@ -565,8 +565,8 @@ on_request: installed_on_request?, options: options)
def expand_requirements def expand_requirements
unsatisfied_reqs = Hash.new { |h, k| h[k] = [] } unsatisfied_reqs = Hash.new { |h, k| h[k] = [] }
formulae = [formula] formulae = [formula]
formula_deps_map = {} formula_deps_map = formula.recursive_dependencies
formula.recursive_dependencies.each { |dep| formula_deps_map[dep.name] = dep } .each_with_object({}) { |dep, h| h[dep.name] = dep }
while (f = formulae.pop) while (f = formulae.pop)
runtime_requirements = runtime_requirements(f) runtime_requirements = runtime_requirements(f)
@ -1206,11 +1206,10 @@ on_request: installed_on_request?, options: options)
def fetch_bottle_tab def fetch_bottle_tab
@fetch_bottle_tab ||= begin @fetch_bottle_tab ||= begin
formula.fetch_bottle_tab formula.fetch_bottle_tab
@bottle_tab_runtime_dependencies = {} @bottle_tab_runtime_dependencies = formula.bottle_tab_attributes
formula.bottle_tab_attributes .fetch("runtime_dependencies", [])
.fetch("runtime_dependencies", []) .each_with_object({}) { |dep, h| h[dep["full_name"]] = dep }
.each { |dep| @bottle_tab_runtime_dependencies[dep["full_name"]] = dep } .freeze
@bottle_tab_runtime_dependencies.freeze
true true
rescue DownloadError, ArgumentError rescue DownloadError, ArgumentError
@fetch_bottle_tab = true @fetch_bottle_tab = true