lib/fourtrack/player.rb in fourtrack-0.2.1 vs lib/fourtrack/player.rb in fourtrack-0.3.1
- old
+ new
@@ -12,9 +12,15 @@
# https://bugs.ruby-lang.org/issues/9790
loop do
break if @io.eof?
zr = Zlib::GzipReader.new(@io)
zr.each_line(&blk)
+ # TODO:
+ # this basically allocates a GIANT string if the file is big
+ # and the amount of data remaining is substantial.
+ # See
+ # https://github.com/ruby/ruby/blob/0adce993578ca4c40afbbc04c5f4679561bd7861/ext/zlib/zlib.c#L2948
+ # Something different is needed - maybe even streaming from commandline gunzip...
unused_bytestr = zr.unused
zr.finish
if unused_bytestr && unused_bytestr.bytesize.nonzero?
@io.pos -= unused_bytestr.bytesize
else