mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-23 15:41:52 +00:00
Speed up reading multiple isos in a row.
This commit is contained in:
parent
086fd24edb
commit
20bb55e1cb
@ -131,6 +131,8 @@ struct VolDescriptor
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
std::list<ISOFileSystem::TreeEntry *> ISOFileSystem::entryFreeList;
|
||||
|
||||
ISOFileSystem::ISOFileSystem(IHandleAllocator *_hAlloc, BlockDevice *_blockDevice)
|
||||
{
|
||||
blockDevice = _blockDevice;
|
||||
@ -156,7 +158,7 @@ ISOFileSystem::ISOFileSystem(IHandleAllocator *_hAlloc, BlockDevice *_blockDevic
|
||||
ERROR_LOG(FILESYS, "ISO looks bogus? trying anyway...");
|
||||
}
|
||||
|
||||
treeroot = new TreeEntry;
|
||||
treeroot = GetTreeEntry();
|
||||
treeroot->isDirectory = true;
|
||||
treeroot->startingPosition = 0;
|
||||
treeroot->size = 0;
|
||||
@ -173,7 +175,7 @@ ISOFileSystem::ISOFileSystem(IHandleAllocator *_hAlloc, BlockDevice *_blockDevic
|
||||
ISOFileSystem::~ISOFileSystem()
|
||||
{
|
||||
delete blockDevice;
|
||||
delete treeroot;
|
||||
ReleaseTreeEntry(treeroot);
|
||||
}
|
||||
|
||||
void ISOFileSystem::ReadDirectory(u32 startsector, u32 dirsize, TreeEntry *root)
|
||||
@ -204,7 +206,7 @@ void ISOFileSystem::ReadDirectory(u32 startsector, u32 dirsize, TreeEntry *root)
|
||||
bool isFile = (dir.flags & 2) ? false : true;
|
||||
bool relative;
|
||||
|
||||
TreeEntry *e = new TreeEntry();
|
||||
TreeEntry *e = GetTreeEntry();
|
||||
if (dir.identifierLength == 1 && (dir.firstIdChar == '\x00' || dir.firstIdChar == '.'))
|
||||
{
|
||||
e->name = ".";
|
||||
@ -591,6 +593,25 @@ std::string ISOFileSystem::EntryFullPath(TreeEntry *e)
|
||||
return path;
|
||||
}
|
||||
|
||||
ISOFileSystem::TreeEntry *ISOFileSystem::GetTreeEntry()
|
||||
{
|
||||
if (entryFreeList.empty())
|
||||
return new TreeEntry();
|
||||
else
|
||||
{
|
||||
TreeEntry *entry = entryFreeList.back();
|
||||
entryFreeList.pop_back();
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
||||
void ISOFileSystem::ReleaseTreeEntry(ISOFileSystem::TreeEntry *entry)
|
||||
{
|
||||
entry->name.clear();
|
||||
entry->children.clear();
|
||||
entryFreeList.push_back(entry);
|
||||
}
|
||||
|
||||
void ISOFileSystem::DoState(PointerWrap &p)
|
||||
{
|
||||
int n = (int) entries.size();
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#include "FileSystem.h"
|
||||
|
||||
@ -53,7 +54,7 @@ private:
|
||||
~TreeEntry()
|
||||
{
|
||||
for (unsigned int i=0; i<children.size(); i++)
|
||||
delete children[i];
|
||||
ISOFileSystem::ReleaseTreeEntry(children[i]);
|
||||
children.clear();
|
||||
}
|
||||
|
||||
@ -89,4 +90,8 @@ private:
|
||||
void ReadDirectory(u32 startsector, u32 dirsize, TreeEntry *root);
|
||||
TreeEntry *GetFromPath(std::string path, bool catchError=true);
|
||||
std::string EntryFullPath(TreeEntry *e);
|
||||
|
||||
static std::list<ISOFileSystem::TreeEntry *> entryFreeList;
|
||||
static TreeEntry *GetTreeEntry();
|
||||
static void ReleaseTreeEntry(TreeEntry *entry);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user