From 0601dbd31b4932d84deb93f7683661a59706b546 Mon Sep 17 00:00:00 2001 From: Neil Millstone Date: Mon, 2 Jul 2007 23:02:54 +0000 Subject: Optimisation for resource loading in Kyra engine svn-id: r27875 --- engines/kyra/resource.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp index 7c15cee2f9..3ff8dd984c 100644 --- a/engines/kyra/resource.cpp +++ b/engines/kyra/resource.cpp @@ -195,15 +195,22 @@ uint8 *Resource::fileData(const char *file, uint32 *size) const { if (!(*cur)->isOpen()) continue; - uint32 fileSize = (*cur)->getFileSize(fileHash); - if (!fileSize) - continue; + uint8* result = (*cur)->getFile(fileHash); + + if (result) { + uint32 fileSize = (*cur)->getFileSize(fileHash); + + if (!fileSize) + continue; + + if (size) + *size = fileSize; + + return result; + } - if (size) - *size = fileSize; - return (*cur)->getFile(fileHash); } } @@ -221,13 +228,15 @@ bool Resource::getFileHandle(const char *file, uint32 *size, Common::File &fileh if (!(*start)->isOpen()) continue; - *size = (*start)->getFileSize(fileHash); + if ((*start)->getFileHandle(fileHash, filehandle)) { + + *size = (*start)->getFileSize(fileHash); - if (!(*size)) - continue; + if (!(*size)) + continue; - if ((*start)->getFileHandle(fileHash, filehandle)) return true; + } } return false; -- cgit v1.2.3