cocos2d/cocos2d-x — pull request #1562 by mingulov (2012-11-08 12:01:09+00:00)
Title: Android: Access to files from APK is boosted

Open APK file just once and cache a file list information (name and position inside archive). Also a general ZipFile helper class is created to read multiple files from Zip archives - might be used for another platforms if needed.

Previously it was so for each separate file access operation:
- Open zip archive, initially parse its structure (unzOpen)
- Locate the particular file there by a linear search through full archive (unzLocateFile).
So if file does not exist - still an archive has to be handled fully, even slower than a file exists.
- Read file.
- Close zip archive

After this commit:
- Once - open zip/apk file and collect file list information
(average consumed time - the same like a search for 2 different files by unzLocateFile)
- When needed - directly retrieve file position inside the archive, setting it up to the zip reader and reading file

ZipFile class is located in support/zip_support/ZipUtils.h and .cpp to prevent creation of a new files and adding them to multiple project files.

std::map is used to store file list information, if supported by a platform - might be changed to std::unordered_map locally (defined at ZipUtils.cpp).

Speedup is visible even on just a simple TestCpp project on TextureCacheTest. On more complex projects with a lot assets / multiple loading / reloading operations - speedup is much more significant.