[前][次][番号順一覧][スレッド一覧]

ruby-changes:57102

From: Yusuke <ko1@a...>
Date: Fri, 16 Aug 2019 21:28:38 +0900 (JST)
Subject: [ruby-changes:57102] Yusuke Endoh: 229ae3269d (master): lib/rdoc/store.rb: Use `Marshal.dump(obj, io)`

https://git.ruby-lang.org/ruby.git/commit/?id=229ae3269d

From 229ae3269d622954295e4220fa7bc3298cad8b1d Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Fri, 16 Aug 2019 21:27:05 +0900
Subject: lib/rdoc/store.rb: Use `Marshal.dump(obj, io)`

instead of dumping obj to a string and then saving the string.
It omits object creation.

diff --git a/lib/rdoc/store.rb b/lib/rdoc/store.rb
index f420fc2..0f6cd06 100644
--- a/lib/rdoc/store.rb
+++ b/lib/rdoc/store.rb
@@ -795,10 +795,8 @@ class RDoc::Store https://github.com/ruby/ruby/blob/trunk/lib/rdoc/store.rb#L795
 
     return if @dry_run
 
-    marshal = Marshal.dump @cache
-
     File.open cache_path, 'wb' do |io|
-      io.write marshal
+      Marshal.dump @cache, io
     end
   end
 
@@ -871,10 +869,8 @@ class RDoc::Store https://github.com/ruby/ruby/blob/trunk/lib/rdoc/store.rb#L869
 
     FileUtils.rm_f to_delete
 
-    marshal = Marshal.dump klass
-
     File.open path, 'wb' do |io|
-      io.write marshal
+      Marshal.dump klass, io
     end
   end
 
@@ -896,10 +892,8 @@ class RDoc::Store https://github.com/ruby/ruby/blob/trunk/lib/rdoc/store.rb#L892
 
     return if @dry_run
 
-    marshal = Marshal.dump method
-
     File.open method_file(full_name, method.full_name), 'wb' do |io|
-      io.write marshal
+      Marshal.dump method, io
     end
   end
 
@@ -918,10 +912,8 @@ class RDoc::Store https://github.com/ruby/ruby/blob/trunk/lib/rdoc/store.rb#L912
 
     return if @dry_run
 
-    marshal = Marshal.dump page
-
     File.open path, 'wb' do |io|
-      io.write marshal
+      Marshal.dump page, io
     end
   end
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]