summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/package.rb
diff options
context:
space:
mode:
authorPaul Kmiec <[email protected]>2023-05-01 08:45:54 -0700
committerPaul Kmiec <[email protected]>2023-05-05 09:29:58 -0700
commite5a8faaa70337ffad6ee2a99e00c0ea3b3c69ca0 (patch)
tree1af207d1654c68c525e8eda2e20bebe661e57966 /lib/axlsx/package.rb
parent67aefd7705df82e43a8670102400a5abab49f6e8 (diff)
downloadcaxlsx-e5a8faaa70337ffad6ee2a99e00c0ea3b3c69ca0.tar.gz
caxlsx-e5a8faaa70337ffad6ee2a99e00c0ea3b3c69ca0.zip
Introduce BufferedZipOutputStream to avoid lots of small writes to Zip::OutputStream
The BufferedZipOutputStream is a drop-in replacement for Zip::OutputStream similar to ZipCommand.
Diffstat (limited to 'lib/axlsx/package.rb')
-rw-r--r--lib/axlsx/package.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/axlsx/package.rb b/lib/axlsx/package.rb
index dd0432cd..b4116f76 100644
--- a/lib/axlsx/package.rb
+++ b/lib/axlsx/package.rb
@@ -111,7 +111,7 @@ module Axlsx
zip_provider = if zip_command
ZipCommand.new(zip_command)
else
- Zip::OutputStream
+ BufferedZipOutputStream
end
Relationship.initialize_ids_cache
zip_provider.open(output) do |zip|
@@ -133,8 +133,9 @@ module Axlsx
return false unless !confirm_valid || self.validate.empty?
Relationship.initialize_ids_cache
- zip = write_parts(Zip::OutputStream.new(StringIO.new.binmode, true))
- stream = zip.close_buffer
+ stream = BufferedZipOutputStream.write_buffer do |zip|
+ write_parts(zip)
+ end
stream.rewind
stream
ensure