Kouhei Sutou 2019-03-01 18:12:50 +0900 (Fri, 01 Mar 2019) Revision: 987a1d46bed896cb699c3fb848f08f6da335a771 https://github.com/ranguba/chupa-text/commit/987a1d46bed896cb699c3fb848f08f6da335a771 Message: gzip: reduce memory usage Modified files: lib/chupa-text/decomposers/gzip.rb Modified: lib/chupa-text/decomposers/gzip.rb (+11 -10) =================================================================== --- lib/chupa-text/decomposers/gzip.rb 2019-03-01 18:10:14 +0900 (c06490b) +++ lib/chupa-text/decomposers/gzip.rb 2019-03-01 18:12:50 +0900 (7733254) @@ -1,4 +1,4 @@ -# Copyright (C) 2013 Kouhei Sutou <kou****@clear*****> +# Copyright (C) 2013-2019 Kouhei Sutou <kou****@clear*****> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -14,7 +14,6 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "stringio" require "zlib" module ChupaText @@ -34,16 +33,18 @@ module ChupaText end def decompose(data) - reader = Zlib::GzipReader.new(StringIO.new(data.body)) - uri = nil - case data.extension - when "gz" + data.open do |input| + reader = Zlib::GzipReader.new(input) + uri = nil + case data.extension + when "gz" uri = data.uri.to_s.gsub(/\.gz\z/i, "") - when "tgz" - uri = data.uri.to_s.gsub(/\.tgz\z/i, ".tar") + when "tgz" + uri = data.uri.to_s.gsub(/\.tgz\z/i, ".tar") + end + extracted = VirtualFileData.new(uri, reader, :source_data => data) + yield(extracted) end - extracted = VirtualFileData.new(uri, reader, :source_data => data) - yield(extracted) end end end -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190301/b2b4e00e/attachment-0001.html>