Skip to content

Commit

Permalink
Refactor|FS1: Avoid manipulating the open-files list in accessFile()
Browse files Browse the repository at this point in the history
Restructed logic for interpreted file instantiation so as to avoid
manipulating the open-files list when answering is-file-accessible
queries. In turn this means that one fewer DFile handle is needed,
further improving startup performance.

Rather than returning a handle to the opened file (that which was
added to the opened-file list), tryOpenFile() now returns the file
itself (leaving it to the caller to decide whether to list and/or
index it later if needed).
  • Loading branch information
danij-deng committed Oct 16, 2012
1 parent 268f073 commit e6daa6a
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 118 deletions.
35 changes: 21 additions & 14 deletions doomsday/engine/portable/include/fs_main.h
Expand Up @@ -170,15 +170,6 @@ namespace de

int removeFiles(char const* const* paths, int num, bool permitRequired = false);

/**
* Find a lump in the Zip LumpIndex.
*
* @param path Path to search for. Relative paths are made absolute if necessary.
* @param lumpIdx If not @c NULL the translated lumpnum within the owning file object is written here.
* @return File system object representing the file which contains the found lump else @c NULL.
*/
AbstractFile* findLumpFile(char const* path, int* lumpIdx = 0);

/// @return Number of lumps in the currently active LumpIndex.
int lumpCount();

Expand Down Expand Up @@ -342,13 +333,14 @@ namespace de
Instance* d;

/**
* @param file Handle to the file to be interpreted.
* @param hndl Handle to the file to be interpreted. Ownership is passed to
* the interpreted file instance.
* @param path Absolute VFS path by which the interpreted file will be known.
* @param info Prepared info metadata for the file.
*
* @return The interpreted AbstractFile file instance.
*/
AbstractFile& interpret(DFile& file, char const* path, LumpInfo const& info);
AbstractFile& interpret(DFile& hndl, char const* path, LumpInfo const& info);

/**
* Adds a file to any relevant indexes.
Expand All @@ -366,10 +358,25 @@ namespace de

bool unloadFile(char const* path, bool permitRequired = false, bool quiet = false);

FILE* findRealFile(char const* path, char const* mymode, ddstring_t** foundPath);
DFile* tryOpenLump(char const* path, char const* mode, size_t baseOffset,
bool allowDuplicate, LumpInfo& info);

DFile* tryOpenNativeFile(char const* path, char const* mode, size_t baseOffset,
bool allowDuplicate, LumpInfo& info);

AbstractFile* tryOpenFile(char const* path, char const* mode, size_t baseOffset, bool allowDuplicate);

DFile* tryOpenFile2(char const* path, char const* mode, size_t baseOffset, bool allowDuplicate);
DFile* tryOpenFile(char const* path, char const* mode, size_t baseOffset, bool allowDuplicate);
FILE* findRealFile(char const* path, char const* mymode, AutoStr** foundPath = 0);

public:
/**
* Find a lump in the Zip LumpIndex.
*
* @param path Path to search for. Relative paths are made absolute if necessary.
* @param lumpIdx If not @c NULL the translated lumpnum within the owning file object is written here.
* @return File system object representing the file which contains the found lump else @c NULL.
*/
AbstractFile* findLumpFile(char const* path, int* lumpIdx = 0);
};

} // namespace de
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/dd_games.cpp
Expand Up @@ -335,7 +335,7 @@ static int locateAllResourcesWorker(void* parameters)
{
Game* game = *i;

VERBOSE( Con_Printf("Locating resources for \"%s\"...\n", Str_Text(&game->title())) )
Con_Message("Locating resources for \"%s\"...\n", Str_Text(&game->title()));

gameCollection->locateStartupResources(*game);
Con_SetProgress((n + 1) * 200 / gameCollection->count() - 1);
Expand Down

0 comments on commit e6daa6a

Please sign in to comment.