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:
parent
e3c2885698
commit
0514a74794
1 changed files with 6 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue