[Scummvm-cvs-logs] SF.net SVN: scummvm:[42637] scummvm/trunk/common/unarj.cpp

wjpalenstijn at users.sourceforge.net wjpalenstijn at users.sourceforge.net
Tue Jul 21 11:39:58 CEST 2009


Revision: 42637
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42637&view=rev
Author:   wjpalenstijn
Date:     2009-07-21 09:39:58 +0000 (Tue, 21 Jul 2009)

Log Message:
-----------
Use a BufferedReadStream to buffer ArjFile's input to reduce memory usage

Modified Paths:
--------------
    scummvm/trunk/common/unarj.cpp

Modified: scummvm/trunk/common/unarj.cpp
===================================================================
--- scummvm/trunk/common/unarj.cpp	2009-07-21 07:02:18 UTC (rev 42636)
+++ scummvm/trunk/common/unarj.cpp	2009-07-21 09:39:58 UTC (rev 42637)
@@ -105,7 +105,7 @@
 	void decode(int32 origsize);
 	void decode_f(int32 origsize);
 
-	MemoryReadStream *_compressed;
+	BufferedReadStream *_compressed;
 	MemoryWriteStream *_outstream;
 
 //protected:
@@ -360,6 +360,9 @@
 		return false;
 
 	ArjHeader *hdr = _headers[_fileMap[filename]];
+
+	// TODO: It would be good if ArjFile could decompress files in a streaming
+	// mode, so it would not need to pre-allocate the entire output.
 	byte *uncompressedData = (byte *)malloc(hdr->origSize);
 
 	File archiveFile;
@@ -372,10 +375,11 @@
 	} else {
 		ArjDecoder *decoder = new ArjDecoder(hdr);
 
-		byte *compressedData = (byte *)malloc(hdr->compSize);
-		archiveFile.read(compressedData, hdr->compSize);
-
-		decoder->_compressed = new MemoryReadStream(compressedData, hdr->compSize, true);
+		// TODO: It might not be appropriate to use this wrapper inside ArjFile.
+		// If reading from archiveFile directly is too slow to be usable,
+		// maybe the filesystem code should instead wrap its files
+		// in a BufferedReadStream.
+		decoder->_compressed = new BufferedReadStream(&archiveFile, 4096, false);
 		decoder->_outstream = new MemoryWriteStream(uncompressedData, hdr->origSize);
 
 		if (hdr->method == 1 || hdr->method == 2 || hdr->method == 3)


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list