os/mac/mach: simplify

We can avoid having to define a local variable and then reference it
inside these blocks by passing a proc instead.
This commit is contained in:
Carlo Cabrera 2023-07-27 12:00:10 +08:00
parent acae97e70f
commit b80940e1d8
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -89,18 +89,15 @@ module MachOShim
def dynamically_linked_libraries(except: :none, resolve_variable_references: true) def dynamically_linked_libraries(except: :none, resolve_variable_references: true)
lcs = macho.dylib_load_commands.reject { |lc| lc.type == except } lcs = macho.dylib_load_commands.reject { |lc| lc.type == except }
names = lcs.map(&:name).map(&:to_s).uniq names = lcs.map(&:name).map(&:to_s).uniq
names.map!(&method(:resolve_variable_name)) if resolve_variable_references
names.map! { |name| resolve_variable_name(name) } if resolve_variable_references
names names
end end
def rpaths(resolve_variable_references: true) def rpaths(resolve_variable_references: true)
names = macho.rpaths names = macho.rpaths
names.map!(&method(:resolve_variable_name)) if resolve_variable_references
names.map! { |name| resolve_variable_name(name) } if resolve_variable_references
names names
end end