[前][次][番号順一覧][スレッド一覧]

ruby-changes:44795

From: normal <ko1@a...>
Date: Tue, 22 Nov 2016 08:50:35 +0900 (JST)
Subject: [ruby-changes:44795] normal:r56868 (trunk): resolv: use symbol proc when possible

normal	2016-11-22 08:50:31 +0900 (Tue, 22 Nov 2016)

  New Revision: 56868

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56868

  Log:
    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

  Modified files:
    trunk/lib/resolv.rb
Index: lib/resolv.rb
===================================================================
--- lib/resolv.rb	(revision 56867)
+++ lib/resolv.rb	(revision 56868)
@@ -25,7 +25,7 @@ end https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L25
 #
 #   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 https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L722
       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 https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L935
           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'

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]