ruby-changes:44794
From: normal <ko1@a...>
Date: Tue, 22 Nov 2016 08:50:30 +0900 (JST)
Subject: [ruby-changes:44794] normal:r56867 (trunk): socket: use symbol proc for IO#close loops
normal 2016-11-22 08:50:25 +0900 (Tue, 22 Nov 2016) New Revision: 56867 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56867 Log: socket: use symbol proc for IO#close loops Made possible by r56795, this reduces human and byte code size. * ext/socket/lib/socket.rb (self.ip_sockets_port0, self.tcp_server_sockets_port0, self.tcp_server_sockets, self.udp_server_sockets): use symbol proc Modified files: trunk/ext/socket/lib/socket.rb Index: ext/socket/lib/socket.rb =================================================================== --- ext/socket/lib/socket.rb (revision 56866) +++ ext/socket/lib/socket.rb (revision 56867) @@ -675,10 +675,10 @@ class Socket < BasicSocket https://github.com/ruby/ruby/blob/trunk/ext/socket/lib/socket.rb#L675 end } rescue Errno::EADDRINUSE - sockets.each {|s| s.close } + sockets.each(&:close) retry rescue Exception - sockets.each {|s| s.close } + sockets.each(&:close) raise end sockets @@ -695,7 +695,7 @@ class Socket < BasicSocket https://github.com/ruby/ruby/blob/trunk/ext/socket/lib/socket.rb#L695 s.listen(Socket::SOMAXCONN) } rescue Exception - sockets.each {|s| s.close } + sockets.each(&:close) raise end sockets @@ -758,7 +758,7 @@ class Socket < BasicSocket https://github.com/ruby/ruby/blob/trunk/ext/socket/lib/socket.rb#L758 raise last_error end rescue Exception - sockets.each {|s| s.close } + sockets.each(&:close) raise end end @@ -766,7 +766,7 @@ class Socket < BasicSocket https://github.com/ruby/ruby/blob/trunk/ext/socket/lib/socket.rb#L766 begin yield sockets ensure - sockets.each {|s| s.close } + sockets.each(&:close) end else sockets @@ -927,7 +927,7 @@ class Socket < BasicSocket https://github.com/ruby/ruby/blob/trunk/ext/socket/lib/socket.rb#L927 begin yield sockets ensure - sockets.each {|s| s.close } if sockets + sockets.each(&:close) if sockets end else sockets -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/