From cb528ff3c1a9e5a9a939e299b0faf10360d1292d Mon Sep 17 00:00:00 2001 From: normal Date: Mon, 21 Nov 2016 23:13:16 +0000 Subject: 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 --- lib/open3.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/open3.rb') diff --git a/lib/open3.rb b/lib/open3.rb index ddfad66436..5ff1012b70 100644 --- a/lib/open3.rb +++ b/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 -- cgit v1.2.3