ruby-changes:44793
From: normal <ko1@a...>
Date: Tue, 22 Nov 2016 08:13:20 +0900 (JST)
Subject: [ruby-changes:44793] normal:r56866 (trunk): lib/open3: favor symbol proc when possible
normal 2016-11-22 08:13:16 +0900 (Tue, 22 Nov 2016) New Revision: 56866 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56866 Log: 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 Modified files: trunk/lib/open3.rb Index: lib/open3.rb =================================================================== --- lib/open3.rb (revision 56865) +++ lib/open3.rb (revision 56866) @@ -198,13 +198,13 @@ module Open3 https://github.com/ruby/ruby/blob/trunk/lib/open3.rb#L198 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 https://github.com/ruby/ruby/blob/trunk/lib/open3.rb#L601 # 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 https://github.com/ruby/ruby/blob/trunk/lib/open3.rb#L650 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/