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

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

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

View file

@ -675,10 +675,10 @@ class Socket < BasicSocket
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
s.listen(Socket::SOMAXCONN)
}
rescue Exception
sockets.each {|s| s.close }
sockets.each(&:close)
raise
end
sockets
@ -758,7 +758,7 @@ class Socket < BasicSocket
raise last_error
end
rescue Exception
sockets.each {|s| s.close }
sockets.each(&:close)
raise
end
end
@ -766,7 +766,7 @@ class Socket < BasicSocket
begin
yield sockets
ensure
sockets.each {|s| s.close }
sockets.each(&:close)
end
else
sockets
@ -927,7 +927,7 @@ class Socket < BasicSocket
begin
yield sockets
ensure
sockets.each {|s| s.close } if sockets
sockets.each(&:close) if sockets
end
else
sockets