1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

resolv: use symbol proc when possible

This reduces both human code and bytecode.

lib/resolv.rb (sender_for, Config.parse_resolv_conf): use symbol proc

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
normal 2016-11-21 23:50:31 +00:00
parent 0514a74794
commit 6d7dc8f7d5

View file

@ -25,7 +25,7 @@ end
# #
# Resolv::DNS.open do |dns| # Resolv::DNS.open do |dns|
# ress = dns.getresources "www.ruby-lang.org", Resolv::DNS::Resource::IN::A # ress = dns.getresources "www.ruby-lang.org", Resolv::DNS::Resource::IN::A
# p ress.map { |r| r.address } # p ress.map(&:address)
# ress = dns.getresources "ruby-lang.org", Resolv::DNS::Resource::IN::MX # ress = dns.getresources "ruby-lang.org", Resolv::DNS::Resource::IN::MX
# p ress.map { |r| [r.exchange.to_s, r.preference] } # p ress.map { |r| [r.exchange.to_s, r.preference] }
# end # end
@ -722,9 +722,7 @@ class Resolv
def close def close
socks = @socks socks = @socks
@socks = nil @socks = nil
if socks socks.each(&:close) if socks
socks.each {|sock| sock.close }
end
end end
class Sender # :nodoc: class Sender # :nodoc:
@ -937,9 +935,7 @@ class Resolv
f.each {|line| f.each {|line|
line.sub!(/[#;].*/, '') line.sub!(/[#;].*/, '')
keyword, *args = line.split(/\s+/) keyword, *args = line.split(/\s+/)
args.each { |arg| args.each(&:untaint)
arg.untaint
}
next unless keyword next unless keyword
case keyword case keyword
when 'nameserver' when 'nameserver'