mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
lib/open3: favor symbol proc when possible
It reduces both human and machine code; as well as reducing the confusion from variable naming. * lib/open3.rb (popen_run, pipeline, pipeline_run): avoid capture git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f845a9ef76
commit
e3c2885698
1 changed files with 6 additions and 6 deletions
12
lib/open3.rb
12
lib/open3.rb
|
@ -198,13 +198,13 @@ module Open3
|
|||
end
|
||||
pid = spawn(*cmd, opts)
|
||||
wait_thr = Process.detach(pid)
|
||||
child_io.each {|io| io.close }
|
||||
child_io.each(&:close)
|
||||
result = [*parent_io, wait_thr]
|
||||
if defined? yield
|
||||
begin
|
||||
return yield(*result)
|
||||
ensure
|
||||
parent_io.each{|io| io.close }
|
||||
parent_io.each(&:close)
|
||||
wait_thr.join
|
||||
end
|
||||
end
|
||||
|
@ -601,7 +601,7 @@ module Open3
|
|||
#
|
||||
def pipeline(*cmds, **opts)
|
||||
pipeline_run(cmds, opts, [], []) {|ts|
|
||||
ts.map {|t| t.value }
|
||||
ts.map(&:value)
|
||||
}
|
||||
end
|
||||
module_function :pipeline
|
||||
|
@ -650,13 +650,13 @@ module Open3
|
|||
r = r2
|
||||
}
|
||||
result = parent_io + [wait_thrs]
|
||||
child_io.each {|io| io.close }
|
||||
child_io.each(&:close)
|
||||
if defined? yield
|
||||
begin
|
||||
return yield(*result)
|
||||
ensure
|
||||
parent_io.each{|io| io.close }
|
||||
wait_thrs.each {|t| t.join }
|
||||
parent_io.each(&:close)
|
||||
wait_thrs.each(&:join)
|
||||
end
|
||||
end
|
||||
result
|
||||
|
|
Loading…
Add table
Reference in a new issue