Skip to content

Commit 5ffedc0

Browse files
mameaycabta
authored andcommitted
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.
1 parent 1d7cf02 commit 5ffedc0

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

lib/rdoc/store.rb

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -795,10 +795,8 @@ def save_cache
795795

796796
return if @dry_run
797797

798-
marshal = Marshal.dump @cache
799-
800798
File.open cache_path, 'wb' do |io|
801-
io.write marshal
799+
Marshal.dump @cache, io
802800
end
803801
end
804802

@@ -871,10 +869,8 @@ def save_class klass
871869

872870
FileUtils.rm_f to_delete
873871

874-
marshal = Marshal.dump klass
875-
876872
File.open path, 'wb' do |io|
877-
io.write marshal
873+
Marshal.dump klass, io
878874
end
879875
end
880876

@@ -896,10 +892,8 @@ def save_method klass, method
896892

897893
return if @dry_run
898894

899-
marshal = Marshal.dump method
900-
901895
File.open method_file(full_name, method.full_name), 'wb' do |io|
902-
io.write marshal
896+
Marshal.dump method, io
903897
end
904898
end
905899

@@ -918,10 +912,8 @@ def save_page page
918912

919913
return if @dry_run
920914

921-
marshal = Marshal.dump page
922-
923915
File.open path, 'wb' do |io|
924-
io.write marshal
916+
Marshal.dump page, io
925917
end
926918
end
927919

0 commit comments

Comments
 (0)