From 6d7dc8f7d5e57431bebb9252e2ddf89417bf283f Mon Sep 17 00:00:00 2001 From: normal Date: Mon, 21 Nov 2016 23:50:31 +0000 Subject: [PATCH] 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 --- lib/resolv.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/resolv.rb b/lib/resolv.rb index bff673c990..6e7fb98733 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -25,7 +25,7 @@ end # # Resolv::DNS.open do |dns| # 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 # p ress.map { |r| [r.exchange.to_s, r.preference] } # end @@ -722,9 +722,7 @@ class Resolv def close socks = @socks @socks = nil - if socks - socks.each {|sock| sock.close } - end + socks.each(&:close) if socks end class Sender # :nodoc: @@ -937,9 +935,7 @@ class Resolv f.each {|line| line.sub!(/[#;].*/, '') keyword, *args = line.split(/\s+/) - args.each { |arg| - arg.untaint - } + args.each(&:untaint) next unless keyword case keyword when 'nameserver'