[Scummvm-cvs-logs] scummvm master -> f23ca8b62b6be15e570311dcaad301067c8e052a

lordhoto lordhoto at gmail.com
Mon Apr 30 00:14:19 CEST 2012


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
f23ca8b62b COMMON: Use the file cache in ZipArchive::listMembers for performance.


Commit: f23ca8b62b6be15e570311dcaad301067c8e052a
    https://github.com/scummvm/scummvm/commit/f23ca8b62b6be15e570311dcaad301067c8e052a
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-04-29T15:09:56-07:00

Commit Message:
COMMON: Use the file cache in ZipArchive::listMembers for performance.

This avoids a new iteration through the .zip file for every listMember call.
Instead it uses the "_hash" HashMap, which already contains all the filenames
and is filled on initializing the ZipArchive by unzOpen.

Changed paths:
    common/unzip.cpp



diff --git a/common/unzip.cpp b/common/unzip.cpp
index 8cfcd60..ab65934 100644
--- a/common/unzip.cpp
+++ b/common/unzip.cpp
@@ -1463,22 +1463,16 @@ bool ZipArchive::hasFile(const String &name) const {
 }
 
 int ZipArchive::listMembers(ArchiveMemberList &list) const {
-	int matches = 0;
-	int err = unzGoToFirstFile(_zipFile);
+	int members = 0;
 
-	while (err == UNZ_OK) {
-		char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
-		if (unzGetCurrentFileInfo(_zipFile, NULL,
-		                          szCurrentFileName, sizeof(szCurrentFileName)-1,
-		                          NULL, 0, NULL, 0) == UNZ_OK) {
-			list.push_back(ArchiveMemberList::value_type(new GenericArchiveMember(szCurrentFileName, this)));
-			matches++;
-		}
-
-		err = unzGoToNextFile(_zipFile);
+	const unz_s *const archive = (const unz_s *)_zipFile;
+	for (ZipHash::const_iterator i = archive->_hash.begin(), end = archive->_hash.end();
+	     i != end; ++i) {
+		list.push_back(ArchiveMemberList::value_type(new GenericArchiveMember(i->_key, this)));
+		++members;
 	}
 
-	return matches;
+	return members;
 }
 
 const ArchiveMemberPtr ZipArchive::getMember(const String &name) const {






More information about the Scummvm-git-logs mailing list