summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-21 23:13:16 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-21 23:13:16 +0000
commite3c288569833b6777e7ecc0bbc26f8e6ca8f2ba7 (patch)
treebdb141407c053db2f856136fc7b46f9c72dd9bde
parentf845a9ef76c0195254ded79c85c24332534f4057 (diff)
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
-rw-r--r--lib/open3.rb12
1 files changed, 6 insertions, 6 deletions
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